如何在 codeigniter 中执行排序、搜索、分页 [英] how to perform sorting,search,pagination in codeigniter
本文介绍了如何在 codeigniter 中执行排序、搜索、分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 codeigniter 的新手.我想搜索、排序并将分页应用于我的表格.我尽力了.当搜索代码起作用时,排序可能不起作用.我无法在一个表中执行这三个操作.请帮我.
解决方案
use
I'm a fresher in codeigniter. I want to search,sort and apply pagination to my table. I tried my best.when search code is working sorting may not work. i can't perform these three actions in a single table. please help me.
解决方案
use Bootstrap datatables. It has in built search, Sort and pagination too.
Sample of My code
In View
<div style="clear: both; margin-top: 35px"></div>
<div class="container">
<div class="col-sm-12" style="padding: 0px">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 " style="padding-right:0px;">
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th width="20%"></th>
<th width="15%"></th>
<th width="20%"></th>
<th width="15%"></th>
<th width="10%"></th>
</tr>
</thead>
<tbody>
<?
foreach ( $ as $ )
{
?>
<tr>
<td><?php echo $['']?></td>
<td><?php echo $['']?></td>
<td><?php echo $['']?></td>
<td><?php echo $['']?></td>
</tr>
<?
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
In Controller
$data[''] = $this->model_name->function_name();
In Header
<link href="<?php echo base_url(); ?>css/bootstrap.css" rel="stylesheet" />
<link href="<?php echo base_url(); ?>css/bootstrap-glyphicons.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet" />
Output
这篇关于如何在 codeigniter 中执行排序、搜索、分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文