框架结构搜索分页的奇怪问题?
本帖最后由 seahorse 于 2013-7-30 15:10 编辑网页采用iframeset框架结构:查询表单所在框架为iframe_top ,显示查询结果的表格的视图在框架iframe_content中,搜索表单提交到iframe_content框架。
搜索条件所在的视图文件_top.php关键代码为:
<formmethod=”get”action=”<?phpsite_url(‘product/search_result’); ?>”target=”iframe_content”>关键字:<input type=”text” name=”keyword” />分类:<select name=’category’ id=’category’><option value=”1”>空调</option><option value=”2”>电视</option><option value=”3”>洗衣机</option></select>
控制器product.php文件的search_result方法的关键代码如下:
functionsearch_result(){ $keyword=trim($this->input->get(‘keyword’, TRUE)); $category= $this->input->get(‘category’); // 调用模型M_model的get_product_count方法获取符合搜索条件产品的数量 $product_count= $this->M_model->get_product_count($keyword, $category);
$config[‘base_url’]= site_url(“product/search_result?keyword=$keyword&category=$category “); $config[‘total_rows’] = $product_count; $config[‘per_page’] = 5; $config[‘page_query_string’]= TRUE; $config[‘query_string_segment’]= ‘searchpage’; $config[‘first_link’] =’首页’; $config[‘last_link’] = ’尾页’; $config[‘prev_link’] = ’上一页’; $config[‘next_link’]= ’下一页’; $config[‘full_tag_open’] = ‘<p>’; $config[‘full_tag_close’] = ‘</p>’;
$this->pagination->initialize($config); // 调用模型M_model的get_product_search_result方法获取符合搜索条件产品 $data[‘result’]= $this-> M_model->get_product_search_result($keyword, $category); $this->load->view(‘_content’,$data);}
iframe_content框架内载入的视图文件_content.php文件关键代码为:
<table> <thead> <tr> <th>序号</th> <th>产品</th> <th>价格</th> </tr> <?phpforeach ($result as $row): ?> <tr> <td><?phpecho $row->id;?></td> <td><?phpecho $row->name;?></td> <td><?phpecho $row->price;?></td> </tr> <?phpendforeach; ?></table> <br><p> <?php echo$this->pagination->create_links();?> </p>
搜索结果能够正常显示,在不点击分页时,各个分页链接的字符串是正常的。例如:http://localhost/shop/index.php/product/search_result?keyword=asd&category=2&searpage=3问题:当点击下一页后,分页链接中的查询字符串里面的搜索条件就变成空了。链接就变成如下形式:http://localhost/shop/index.php/product/search_result?keyword=&category=&searpage=3从而导致搜索结果变成了所有内容。
请问各位,这个问题怎么解决? 顶这个问题我也遇到了,相当的奇怪,如果分页代码去掉,数据就全都出来了,但是加上分页后 点击下一页就会出现空白,可是分页代码是不可能写错的 ,数据也调出来了 http://localhost/shop/index.php/product/search_result?keyword=&category=&searpage=3 主要还是这个原因吧。。
本帖最后由 seahorse 于 2013-8-6 16:54 编辑
是这个原因,参数写错了 本帖最后由 seahorse 于 2013-8-6 16:54 编辑
问题已解决! seahorse 发表于 2013-8-6 16:45
问题已解决!
我也遇到类似问题,如何解决?
求答案
页:
[1]