gpt4 book ai didi

php - 如何使用codeigniter在分页中添加 'div'

转载 作者:行者123 更新时间:2023-11-28 09:53:34 25 4
gpt4 key购买 nike

我有一个分页代码,它以表格格式显示结果,因为这是我在代码中定义的,但问题是我想更改代码,以便我可以编辑结果并将其格式化div 语句。 Pliz 帮助我确定在所有三个字段(即类(class)、成绩、位置)中包含 div 语句的位置,我的意思是,例如我希望我的类(class)可能有一个名为 mydiv n 的 div,在我看来我希望它是这样的(<div class="mydiv">course</div>)。我只上传了下面分页页面的最后一部分。我还包含了调用分页结果的 View 。告诉我在 View 中的什么地方执行此操作,或者简单地说,告诉我如何在我的 View 中分别调用每个元素。

分页 Controller

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

$config['base_url'] = site_url('pagination/index/').'/'.$keys.'/';
$config['per_page'] = $this->limit;
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();

// generate table data
$this->load->library('table');
$this->table->set_empty("&nbsp;");

$heading = array('No','Course', 'Grade', 'Location');

$this->table->set_heading($heading);
$i = 0 + $offset;
foreach ($parents as $parent){
$this->table->add_row(++$i, $parent->course, $parent->grade, $parent->location);
}
$data['table'] = $this->table->generate();

// load view
$this->load->view('paginationview', $data);

查看

<?php echo $pagination; ?>

最佳答案

你可以在 Controller 中使用它

 /*for pagination*/
$config = array();
$config["base_url"] = base_url() . "index.php/dashboard/roomInfo";
$config["total_rows"] = $this->dashboard_model->record_count_all_room_registration();
$config["per_page"] = 5;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

$config["num_links"] = $config["total_rows"] / $config["per_page"];
$config['full_tag_open'] = '<ul class="tsc_pagination tsc_paginationA tsc_paginationA01">';
$config['full_tag_close'] = '</ul>';
$config['prev_link'] = 'First';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="current"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['first_link'] = '&lt;&lt;';
$config['last_link'] = '&gt;&gt;';
$this->pagination->initialize($config);

$config['display_pages'] = FALSE;
$data["links"] = $this->pagination->create_links();
/* pagination ends here */

并在 View 中仅此

    <div class="pagination">
<?php echo $links; ?>
</div>

然后css放在这里

           /*for pagination*/
ul.tsc_pagination { margin:4px 0; padding:0px; overflow:hidden; font:12px 'Tahoma'; list-style-type:none; }
ul.tsc_pagination li { float:left; margin:0px; padding:0px; margin-left:5px; }

ul.tsc_pagination li a { color:black; display:block; text-decoration:none; padding:7px 10px 7px 10px; }


ul.tsc_paginationA li a { color:#FFFFFF; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }

ul.tsc_paginationA01 li a { color:#474747; border:solid 1px #B6B6B6; padding:6px 9px 6px 9px; background:#E6E6E6; background:-moz-linear-gradient(top, #FFFFFF 1px, #F3F3F3 1px, #E6E6E6); background:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0.02, #FFFFFF), color-stop(0.02, #F3F3F3), color-stop(1, #E6E6E6)); }
ul.tsc_paginationA01 li:hover a,
ul.tsc_paginationA01 li.current a { background:#FFFFFF; }
.pagination
{
margin: 0px; color: #3399ff; width:100%;
}
/*pagination css ends up*/

关于php - 如何使用codeigniter在分页中添加 'div',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24989323/

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