【问题标题】:Fetch table contents based on query form in codeigniter在codeigniter中根据查询表单获取表格内容
【发布时间】:2017-09-27 04:40:34
【问题描述】:

我应该使用查询来获取表的内容。就像人们输入计划编号时一样,它应该返回具有该计划编号的所有行。

输出应该是这样的: 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();
    }

【问题讨论】:

    标签: php forms codeigniter


    【解决方案1】:

    像这样更改您的 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();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 1970-01-01
      • 2014-10-22
      • 1970-01-01
      相关资源
      最近更新 更多