|
model
public function list_admin($offset,$pagesize){
$query = $this->db->order_by('admin_id ASC')->limit($pagesize,$offset)->get($this->tablename);
return $query;
}
controller
public function admin_list(){
$page_config['perpage'] = 10; //每页条数
$page_config['part'] = 2; //当前页前后链接数量
$page_config['url'] = 'admin/admin_list?';
$offset = isset($_GET['per_page']) && $_GET['per_page'] != '' ? $_GET['per_page'] : 0;
if ($offset >= 1) {
$offset-=1;
}
$offset = $offset > 0 ? $offset * $page_config['perpage'] : $offset;
$page_config['nowindex'] = isset($_GET['per_page']) && $_GET['per_page'] != '' ? $_GET['per_page'] : 1;
$page_config['total'] = $this->db->count_all_results('ci_admin'); //得到记录总数
$this->mypage->initialize($page_config);
$query = $this->admin_model->list_admin($offset, $page_config['perpage']);
$data['list'] = $query->result_array();
$data['per_page'] = $page_config['nowindex'];
$this->load->view('admin/admin_list', $data);
}
view
<form method="post" action="" name="listForm">
<!-- start goods list -->
<div class="list-div" id="listDiv">
<?php $per_page = isset($_GET['per_page']) ? $_GET['per_page'] : 0; ?>
<table cellpadding="3" cellspacing="1">
<tbody>
<tr>
<th></th><!--goods_id-->
<th>用户姓名</th><!--goods_id-->
<th>邮箱</th><!--goods_name -->
<th>注册时间</th><!--goods_sn-->
<th>登录次数</th><!--shop_price -->
<th>操作</th>
</tr>
<?php foreach($list as $row):?>
<tr>
<td><input type="checkbox" name="checkboxes[]" ></td>
<td class="first-cell"><span><?php echo $row['admin_name']; ?></span></td>
<td align="left"><span><?php echo $row['email']; ?></span></td>
<td align="left"><span><?php echo date("Y-m-d.H:i:s",$row['add_time']); ?></span></td>
<td align="left"><span><?php echo $row['account']; ?></span></td>
<td align="center" nowrap="true" valign="top">
<a href="<?php echo base_url('admin/admin_delete');?>?admin_id=<?php echo $row['admin_id'];?>" title="删除信息"><img src="<?php echo base_url('assets/cishop/admin');?>/images/icon_trash.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!-- end goods list -->
<ul class="pagination">
<?php echo $this->mypage->show(3); ?>
</ul>
</div>
</form>
|
-
-
mypage.rar
2.26 KB, 下载次数: 264
放到application中的libraries中
评分
-
查看全部评分
|