1.控制器代码
1 public function lst() 2 { 3 //field 要查询的字段名称 ,paginate 每页显示多少条 4 $confRes = db(‘conf‘)->field(‘id,cname,ename,value,values‘)->paginate(2); 5 //数据绑定到视图view 6 $this->assign(‘confRes‘,$confRes); 7 return view(); 8 }
2.视图代码
1 <!--循环数据,id为foreach的value --> 2 {volist name="confRes" id="c"} 3 <tr> 4 <td align="center">{$c.id}</td> 5 <td align="center">{$c.cname}</td> 6 <td align="center">{$c.ename}</td> 7 <!--判断值不为空 --> 8 <td align="center">{if condition="$c[‘value‘] neq ‘‘"}{$c.value}{else/}未定义{/if}</td> 9 <td align="center">{if condition="$c[‘values‘] neq ‘‘"}{$c.values}{else/}未定义{/if}</td> 10 11 <td align="center"> 12 <a href="/admin/user/edit/id/6.html" class="btn btn-primary btn-sm shiny"> 13 <i class="fa fa-edit"></i> 编辑 14 </a> 15 <a href="#" onClick="warning(‘确实要删除吗‘, ‘/admin/user/del/id/6.html‘)" class="btn btn-danger btn-sm shiny"> 16 <i class="fa fa-trash-o"></i> 删除 17 </a> 18 </td> 19 </tr> 20 {/volist}
3.分页
1 <div style="padding-top: 15px;text-align: right;" > 2 {$confRes->render()} 3 </div>
原文地址:https://www.cnblogs.com/zifeiyu2018/p/10536734.html
时间: 2024-10-30 21:29:57