php - How can i make to get not only by id but by one more column also -


this

model

public function get_news($newsid= false)     {         if ($newsid === false)         {          $this->db->select('*');          $this->db->from('news');          $this->db->where('status' , 1);          $this->db->where('language' , 2);          return $query->result_array();         $config['per_page']; $this->uri->segment(3);         }         $query = $this->db->get_where('news', array('newsid' => $newsid));         return $query->row_array(); 

controller

public function single($newsid)         {          $data['news_item'] = $this->news_model->get_news($newsid);         if (empty($data['news_item']))         {         show_404();         }         $data['newsid'] = $data['news_item']['newsid'];          $this->load->view('news/single', $data);          } 

view

<?php echo $news_item['tittlenews'];?> 

i have other view foreach news table , want create read more have created on code works fine want make read more newsid , 1 other column mean first check newsid , other colum , show me on view singly

you can use model method this:

 function getby($data){     foreach($data $key=>$value){       $this->db->where($key,$value);     }      $query = $this->db->get('users_table');     return $query->row(); //or $query->result(); want   } 

so call

$this->model->getby( array( 'username'=>'mark', 'id'=>'90', 'email'=>'asd@asd.com' ); ); 

obviously can extend model method as can


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -