drsb77336 2014-10-18 10:03
浏览 56
已采纳

Codeigniter post方法与分页冲突

I have a codeigniter search form which includes a dropdown list (Car) and a checkbox array (Car types). I am using POST method to get values from database but post method conflicts with pagination. Could you please check my code and help me to find the mistake.

Here is my controller

   public function search($offset = 0) {
                $limit = 3;

                $this->load->library('form_validation');
                $this->load->model('model_x');

                $this->form_validation->set_rules('car', 'Car','required');
                $this->form_validation->set_rules('types', 'Car Type','required');

               if($this->form_validation->run()) {

        $car= $this->input->post('car');
        $types = $this->input->post('types'); 

        $this->load->library('pagination');

        $config['base_url'] = 'http://localhost/abc/cont/search/'; 

        // 'http://localhost/abc' is my base url

        $config['total_rows'] = 14;
        $config['per_page'] = 3; 

        $data['pagination'] = $this->pagination->initialize($config);

                if ($this->model_x->did_search($car, $types, $limit, $offset)){

                $data["results"] = $this->model_x->did_search($car, $types, $limit, $offset); 
                $this->load->view("search_ok",$data);           
                }          
                }
                else
                {
                $data['message'] = 'Please select your options.';   

                $this->load->view("search_nok",$data);          
                 }              
           }
  • 写回答

2条回答 默认 最新

  • donglong7338 2014-10-18 10:07
    关注

    Using get parameters for search would be better since besides making pagination easier, it will allow users to access that link directly through Bookmarks or other hyperlinks without needing to go through posting your form every time they need to repeat a "saved" search.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度