开发者

Php sorting doesn't seem to work for me

I have an anchor tag in my table header and it calls a controller method. I used this,

<th width="15%" align="center" class="grid_header">Category
  <?=anchor('customer/basic/'.$keyword.'/Category/'.$this->customerlist->
 fieldTest('dbCatego开发者_如何学Pythonry', $sort_field, $sort_order), 'Category')?></th>

and i have this method,

 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);
   } 

I get the error Parse error: syntax error, unexpected T_VARIABLE in the line

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

Any suggestion...

EDIT: Source: http://codeigniter.com/forums/viewthread/112696/#571876


The default value in your parameters cannot be a variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜