簡體   English   中英

php排序似乎對我不起作用

[英]Php sorting doesn't seem to work for me

我的表頭中有一個定位標記,它調用了控制器方法。 我用這個

<th width="15%" align="center" class="grid_header">Category
  <?=anchor('customer/basic/'.$keyword.'/Category/'.$this->customerlist->
 fieldTest('dbCategory', $sort_field, $sort_order), 'Category')?></th>

我有這種方法

 function Basic($keyword = $this->input->post('keyword'),$sort_field = 'default_field',$sort_order = 'default_order')
    {
        //Using form input to determine what fields to search in the table with $keyword

        $section = $this->input->post('section');
        //Start prepping the query
        foreach($section as $key => $tbl_field) 
        {
            //For first field generate 'like' statement, the rest get 'or_like'
            if($key == 0) {$this->db->like($tbl_field, $keyword); }
            if($key > 0) { $this->db->or_like($tbl_field, $keyword); }
        }
        //Perform the query, and set the results as an array
        $query = $this->db->get('tbl_customer');
        $result = $query->result_array;
        //Sort the Array
        $result = $this->customerlist->orderBy($result, $sort_field, $sort_order);
        $data['customerdata'] = (object)$result;  //I like to work with objects in my views
        print_r($data['customerdata']);
        //Load the view with the sorted search results
        $data['keyword']=$keyword;        //
        $data['sort_field']=$sort_field;  // send these to the view for sorting links
        $data['sort_order']=$sort_order;   //
        $this->load->view('customerdetails', $data);
   } 

我收到錯誤Parse error: syntax error, unexpected T_VARIABLE該行Parse error: syntax error, unexpected T_VARIABLE

function Basic($keyword = $this->input->post('keyword'),$sort_field = 
                    'default_field',$sort_order = 'default_order')

任何建議...

編輯:來源: http : //codeigniter.com/forums/viewthread/112696/#571876

參數中的默認值不能是變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM