标签:
注意分页的方法有两种:一种是thinkphp3.2 自带的 另一种是之前新闻页用过的 显示效果稍有差别
显示效果:
细节问题:
①搜索页面 要加session判断 和 分页
②修改和添加页面需要有session判断
③增删改的权限设置
控制器端:
1 <?php 2 namespace Home\Controller; 3 use Think\Controller; 4 class UserController extends Controller 5 { 6 public function User(){ 7 8 if (session(‘?username‘)) { 9 $m=M(‘fruit‘); 10 //$arr=$m->select(); 11 //var_dump($arr); 12 $total=$m->count(); 13 //$this->assign(‘data‘,$arr); 14 $this->assign(‘sess‘,session(‘username‘)); 15 16 $page=new \Home\Publics\Page($total,3); 17 //$page->limit;//limit n,n 18 $sql="select * from fruit ".$page->limit; 19 $lim=$m->query($sql); 20 $pagelist=$page->fpage(); 21 $this->assign(‘data‘,$lim); 22 $this->assign(‘list‘,$pagelist); 23 $this->display(); 24 } 25 else{ 26 $this->redirect(‘Login/Login‘); 27 } 28 29 30 31 }
前端显示:
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>业务</title> 6 <style type="text/css"> 7 a:link { 8 text-decoration: none; 9 } 10 </style> 11 <script type="text/javascript"> 12 function jump(){ 13 window.location="/tp/index.php/Home/Add/Add"; 14 } 15 </script> 16 <style type="text/css"> 17 #se{ 18 float: left; 19 position: absolute; 20 margin-left: 150px; 21 } 22 23 </style> 24 </head> 25 <body><div id=‘se‘><{$sess}> 您好!</div> 26 <div align="center" display:inline style="width: 1380px;"> 27 <h1>业务主页</h1> 28 <form action="__URL__/search" method="post"> 29 <b>查询</b> 序号:<input type="text" name="ids"> 30 名称:<input type="text" name="name"> 31 价格:<input type="text" name="price"> 32 产地:<input type="text" name="source"> 33 <input type="submit" value="搜索"></input> 34 </form></div><br> 35 <table border="1" width="1000" align="center"> 36 <tr> 37 <th>序号</th> 38 <th>名称</th> 39 <th>价格</th> 40 <th>产地</th> 41 <th>操作</th> 42 </tr> 43 <volist name=‘data‘ id=‘vo‘> 44 <tr> 45 <td><{$vo.ids}></td> 46 <td><{$vo.name}></td> 47 <td><{$vo.price}></td> 48 <td><{$vo.source}></td> 49 <td><a href="/tp/index.php/Home/User/del/ids/<{$vo.ids}>">删除</a> | <a href="/tp/index.php/Home/User/modify/ids/<{$vo.ids}>">修改</a></td> 50 </tr> 51 </volist> 52 53 </table> 54 <div align="center"><{$list}></div> 55 <br> 56 <center> 57 <button onclick="jump()">添加数据</button> 58 </center> 59 </body> 60 </html>
标签:
原文地址:http://www.cnblogs.com/haodayikeshu/p/5500114.html