2017-09-27 68 views
0

我應該使用查詢來獲取表格的內容。就像人們輸入計劃編號一樣,它應該返回具有該計劃編號的所有行。根據查詢表格在codeigniter中獲取表格內容

輸出應該是這樣的: screenshot from php my admin

然而,我的代碼只是重複相匹配的第一個: repeated rows

這是我的代碼:

控制器:

public function show_plan(){ 
    $data['title'] = 'Plan Query'; 

    if($this->uri->segment(3)=='view'){ 
     if(!isset($_POST['btnsubmit'])){ 
      redirect(base_url('query/show_plan')); 
     } 

     $plan = $this->input->post('plan_no_post'); 

     $this->load->model('plan_query_model'); 
     $data['items'] = $this->plan_query_model->check_plan($plan); 
     $this->load->view('plan_query_view', $data); 
    }else{ 
     $this->load->view('query_form', $data); 
    } 
} 

型號:

public function check_plan($plan){ 
$this->load->model('report_lookup_model'); 
     $this->db->where("plan_no='$plan'"); 
     $rs = $this->db->get('plan_key'); 
     return $rs->result_array(); 
    } 

回答

0

更改您的check_plan這樣的功能。

public function check_plan($plan){ 
    $this->load->model('report_lookup_model'); 
    $this->db->where("plan_no", $plan); 
    $rs = $this->db->get('plan_key'); 
    return $rs->result_array(); 
} 
相關問題