controller
public function record() { $r = 10; $m = M(); $query = $m->query('select count(1) as count from winner'); $total = $query[0]['count']; $page = new \Think\Page($total,$r);// 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $page->show();// 分页显示输出 $list = $m->query("select w.id, w.uid, w.create_time, u.username, i.name from winner as w, user as u, item as i where u.id=w.uid and i.id=w.prize_id order by w.create_time limit $page->firstRow, $page->listRows"); $this->assign('list',$list);// 赋值数据集 $this->assign('page',$show);// 赋值分页输出 $this->display(T('Winner@Admin/record')); }
view
<extend name="Public/base"/> <block name="body"> <div class="main-title"> <h2>中奖纪录</h2> </div> <div class="with-padding"> <form id="export-form" method="post" action="{:U('export')}"> <table class="table table-bordered table-striped"> <thead> <tr> <th>序号</th> <th>ID</th> <th>用户名</th> <th>奖品</th> <th>时间</th> </tr> </thead> <tbody> <volist name="list" id="table"> <tr> <td>{$i}</td> <td>{$table.id}</td> <td><a href='/xxx/index.php?s=/admin/user/expandinfo_details/uid/{$table.uid}.html'> {$table.username}</a></td> <td>{$table.name}</td> <td><?php echo date('Y-m-d H:i:s', $table['create_time']);?></td> </tr> </volist> </tbody> </table> </form> </div> {$page} </block>