gpt4 book ai didi

php - Codeigniter - “下一步”按钮更改页面上的值和数据,但 "active"类不会更改

转载 作者:搜寻专家 更新时间:2023-10-30 23:45:35 25 4
gpt4 key购买 nike

我想做的是创建一个分页功能。我已经成功地创建了它。有用。 URI 段改变了一切。这是完美的。但是,有一个小问题。当我按“下一页”按钮或按另一个数字转到下一页时,“第 1 页”由于某种原因仍然突出显示。我无法单击它转到第一页。 “上一个”按钮也会出现。因此,在我转到第二页或除第 1 页以外的任何其他页面后,我无法返回到第一页。我可以返回到第一页的唯一方法是更改​​ URI 段。

我找不到这个特定问题的答案,因此非常感谢任何帮助。谢谢。

我的模型:

public function record_count_sitelog()
{
$uid = $this->uri->segment(4);
return $this->db->get_where('site_log', array('uid' => $uid))->num_rows();
}

public function fetch_users_sitelog($limit, $start)
{
$this->db->order_by("time", "desc"); //ordering it in descending order
$uid = $this->uri->segment(4);
$this->db->limit($limit, $start);

$query = $this->db->get_where('site_log', array('uid' => $uid));

if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}

我的 Controller :

public function site_log() {
$uid = $this->uri->segment(4);

$data = array( 'uid' => $uid
);

$this->load->model('Model_Admin_Pagination');
$this->load->library('pagination');
$this->load->library('table');

$config = array();
$config["base_url"] = base_url() . "admin/users/site_log/". $uid ."/";
$this->db->select('*');
$config["total_rows"] = $this->Model_Admin_Pagination->record_count_sitelog();
$config["per_page"] = 20;
$config["uri_segment"] = 4;
$config["num_links"] = 3;
$config['records'] = $this->db->select('*');
//styling it
$config['full_tag_open'] = '<div class="pull-right"> <ul class="pagination">';
$config['full_tag_close'] = '</div></ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['next_link'] = '→';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '←';
$config['cur_tag_open'] = '<li class="active"><a>';
$config['cur_tag_close'] = '</li></a>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['last_link'] = '»';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['first_link'] = '«';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
//end styling it

$page = ($this->uri->segment(5)) ? $this->uri->segment(5) : 0;
$data["results"] = $this->Model_Admin_Pagination->
fetch_users_sitelog($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();

$this->pagination->initialize($config);

$this->load->view('admin/includes/header');
$this->load->view('admin/view_site_log', $data);
}

我的看法:

    <?php
if (is_array($results))
{
foreach ($results as $data) { ?>
<div> <!--class="col-md-6 col-sm-6"-->
<div class="well pretty-text">
<p>
<h3><font color="#708090">Time:</font> <?php echo date("g:i A", strtotime($data->time)). ' on ' . date("F j, Y", strtotime($data->time)) ?><br></h3>
<b>Current URL:</b> <?php echo $data->current_url ?><br>
Referrer: <?php echo $data->referrer ?><br>
<b>Browser:</b> <?php echo $data->browser ?><br>

Mobile: <?php echo $data->mobile ?><br>
<b>Platform:</b> <?php echo $data->platform ?><br>
<b>User Agent:</b> <?php echo $data->user_agent ?>

</p>
</div>
</div>
<?php } } ?>

<?php echo $this->pagination->create_links(); ?>

最佳答案

你说你的uid$this->uri->segment(4);。如果那是 segment(4),那么在您的 Controller 中,您说 $config["uri_segment"] = 4;

如果您的 URL 类似于:http://example.com/profile/view/1/10 其中 1uid,那么你应该将$config["uri_segment"] = 4;中的4改为5

所以我会替换这一行(在你的 Controller 中):

$config["uri_segment"] = 4;

与:

 $config["uri_segment"] = 5;

关于php - Codeigniter - “下一步”按钮更改页面上的值和数据,但 "active"类不会更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29061046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com