PHP 的DataGrid 分页
2015-06-12 14:08
369 查看
PHP的页面,表格嵌入分页条,小结:
参考:http://www.jeasyui.com/tutorial/datagrid/datagrid2.php
注意:
To load data from remote server, you should
set 'url' peoperty, where server will return JSON format data. see datagrid document for more about the data format.
We defines datagrid columns and
set 'pagination' property to true, which will generate a pagination bar on datagrid bottom. The pagination will send two parameters to server:
page: The page number, start with 1.
rows: The page rows per page.
参考:http://www.jeasyui.com/tutorial/datagrid/datagrid2.php
注意:
To load data from remote server, you should
set 'url' peoperty, where server will return JSON format data. see datagrid document for more about the data format.
We defines datagrid columns and
set 'pagination' property to true, which will generate a pagination bar on datagrid bottom. The pagination will send two parameters to server:
page: The page number, start with 1.
rows: The page rows per page.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="keywords" content="jquery,ui,easy,easyui,web"> <meta name="description" content="easyui help you build your web page easily!"> <title>jQuery EasyUI Demo</title> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> </head> <body> <h1>DataGrid</h1> <table id="tt" class="easyui-datagrid" style="width:600px;height:250px" url="datagrid2_getdata.php" title="Load Data" iconCls="icon-save" rownumbers="true" pagination="true"> <thead> <tr> <th field="itemid" width="80">Item ID</th> <th field="productid" width="80">Product ID</th> <th field="listprice" width="80" align="right">List Price</th> <th field="unitcost" width="80" align="right">Unit Cost</th> <th field="attr1" width="150">Attribute</th> <th field="status" width="60" align="center">Stauts</th> </tr> </thead> </table> </body> </html>
<?php $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; $offset = ($page-1)*$rows; $result = array(); $conn = mysql_connect('127.0.0.1','root','root'); mysql_select_db('mydb',$conn); $rs = mysql_query("select count(*) from item"); $row = mysql_fetch_row($rs); $result["total"] = $row[0]; $rs = mysql_query("select * from item limit $offset,$rows"); $rows = array(); while($row = mysql_fetch_object($rs)){ array_push($rows, $row); } $result["rows"] = $rows; echo json_encode($result); ?>
相关文章推荐
- PHP的JSON处理方式,
- 为什么PHP能够受到大家追捧和喜爱,又为什么饱受嘲讽?
- 用二十秒记住几个PHP基础知识点
- sublime phpcs
- php curl
- PHP安装,报错信息和解决过程
- TP-Link路由器端口映射8081端口的Nexus服务外网无法访问的解决办法
- PHP中读取大文件实现方法详解
- Yii学习笔记之六(HTML生成帮助类api 翻译)
- laravel5学习笔记(3)——复杂的路由
- php结合ACCESS的跨库查询功能
- Response.getWriter() 和Response.getOutputStream冲突
- (转)解析PHP中ob_start()函数的用法
- FragmentPagerAdapter与FragmentStatePagerAdapter区别
- LAMP环境搭建3-PHP5.6
- php 开发环境图文配置
- Windows下PHPUnit安装
- 【AS400系列】通过程序例子说明检查AS400用户密码的API-QSYGETPH
- (转)ThinkPHP系统常量
- PHP 根据IP地址获取所在城市