[英]Return to same page in pagination
| Item | Stock | Description | Action
| Book | 5 | PHP Books | Edit
| Pen | 14 | Gold Pen | Edit
| Pen2 | 2 | Silver Pen | Edit
|Previous|1|2|**3**|4|5|Next|
i have some items in my table on page 3, i wanna edit an item and when i click save the data, i wanna return to this table with same page. 我在第3页的表中有一些项目,我想编辑一个项目,当我单击“保存数据”时,我想返回同一页面的该表。
now, when i click save, i will return to page 1 现在,当我单击“保存”时,我将返回第1页
maybe you have the reference to read, or something because i don't know the keyword. 也许您有参考资料要阅读,或者因为我不知道关键字而有所作为。
Add the page number in a hidden field in the form. 在表单的隐藏字段中添加页码。
After form submission, redirect to that page 提交表单后,重定向到该页面
The page number is the argument you are passing to your controller function: public function index( $page_nbr
= 0) 页码是您要传递给控制器函数的参数: 公共函数索引(
$page_nbr
= 0)
Here is an example: 这是一个例子:
public function index($page_nbr = 0)
{
$this->load->library('pagination');
$config['base_url'] = '/users/index/';
$config['total_rows'] = $this->users_model->count_users();
$config['per_page'] = 40;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['current_page_number'] = $page_nbr;
$this->run('users', $data);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.