2010-08-23 1 views
0

J'ai une balise d'ancrage dans mon en-tête de table et cela appelle une méthode de contrôleur. J'ai utilisé ce,Le tri Php ne semble pas fonctionner pour moi

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

et j'ai cette méthode,

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

Je reçois l'erreur Parse error: syntax error, unexpected T_VARIABLE dans la ligne

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

Toute suggestion ...

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

Répondre

1

La valeur par défaut de vos paramètres ne peut pas être une variable.

+0

regardez ma modification –

+0

Vous avez toujours la fonction Basic ($ keyword = $ this-> input-> post ('mot-clé') ... 'l'erreur d'analyse indique que la valeur par défaut (' $ this-> input-> post ('keyword') ') n'est pas valide La valeur par défaut doit être une * constante * (c'est-à-dire ne pas commencer par un $) –