我应该使用查询来获取表的内容。就像人们输入计划编号时一样,它应该返回带有该计划编号的所有行。
输出应该是这样的: 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 :(得分: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();
}