问个分页传值的问题
他自动回多出来一页而且每内容的。 我点击下一页在点上一页,上一页的内容就没了。是不是$user没传过去? 要如何解决啊。 急!!!function index()
{
$user = $_SESSION['username'];
$data['title']= $user;
$data['info']= $this->custom_model->getInfos($user);
$this->load->view('main',$data);
}
function getInfos($user)
{
$_SESSION['username'] = $user;
$this->load->library('pagination');
$config['base_url'] = base_url().'/index.php/custom/index/';
$config['total_rows'] = $this->db->count_all('custom');
$config['per_page'] = '5';
//$config['num_links'] = '6';
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<div class="pagination">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = 'First';
//$config['first_tag_open'] = '<div>';
//$config['first_tag_close'] = '</div>';
$config['last_link'] = 'Last';
//$config['last_tag_open'] = '<div>';
//$config['last_tag_close'] = '</div>';
$this->pagination->initialize($config);
$sql=$this->db->where("seller", "$user");
$sql=$this->db->order_by("sort", "asc");
$sql=$this->db->get('custom',$config['per_page'],$this->uri->segment(3));
if ($sql->num_rows() > 0)
{
return $sql->result_array();
}
else
{
return false;
}
}
<?php echo $this->pagination->create_links(); ?><br /> $config['base_url'] = base_url().'/index.php/custom/index/';
这里要加上 $user
分页的所有条件,(除了页数),都必须加到 base_url 中 我只要加了这句分页就不对了
$sql=$this->db->where("seller", "$user");
$user=$_SESSION['username'];
$config['user']= $user;
条件我都加上去了 $config['base_url'] = base_url().'/index.php/custom/index/';
这里我没看到 $user 的身影 -_-
在这里拼接字符串,我说的已经很直白了,呵呵
PS: 你应该搞清楚为什么,而不是只问怎么做,因为你不了解原理,所以说很多你可能也理解不了。搞清楚原理很简单,直接看源码。 本帖最后由 atxlin 于 2010-5-12 15:41 编辑
这个$user是session里获得的。
我不知道应该加在 $config['base_url'] = base_url().'/index.php/custom/index/';什么地方。
加在最后好像不对。。。。
$config['base_url'] = base_url().'/index.php/custom/index/'.$user function getInfos($user)
你看看这里,把这个 $user 直接拼接到 URL 中。。。。。。。
我实在是不知道怎么能跟你说清楚了。。。。。。。谁能帮帮我。。。。。。。。。 index.php/custom/index/test/1
如果我想得到url中的test这个值用uri->segment(3)取值吧 唉 怎么说呢 搜索论坛和baidu google 连个带参数搜索的例子都没有。别和我说把参数加在base_url。一加就错了 至于为什么错,不清楚是因为配置不对还是怎么样。估计楼主也是那样的错误 index.php/abc/def/?a=b&c=d
要实现这个请参考 http://codeigniter.org.cn/forums/thread-692-1-1.html
页:
[1]
2