标签:
一、html文件代码
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Basic DataGrid - jQuery EasyUI Demo</title> 6 <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"> 7 <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"> 8 <link rel="stylesheet" type="text/css" href="easyui/demo/demo.css"> 9 <script type="text/javascript" src="easyui/jquery.min.js"></script> 10 <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script> 11 <script type="text/javascript" src="datagrid3.js"></script> 12 </head> 13 <body> 14 初中英语单词与短语大全 15 <table id="dgbox"></table> 16 </body> 17 </html>
二、js文件代码
1 $(function () { 2 $(‘#dgbox‘).datagrid({ 3 width : 500, 4 //url : ‘content.json‘, 5 url : ‘datagrid3.php‘, 6 title : ‘用户列表‘, 7 iconCls : ‘icon-search‘, 8 columns : [[ 9 { 10 field : ‘ch‘, 11 title : ‘汉语‘, 12 }, 13 { 14 field : ‘en‘, 15 title : ‘英语‘, 16 }, 17 { 18 field : ‘fenlei2‘, 19 title : ‘分类‘, 20 }, 21 ]], 22 pagination : true, 23 pageSize : 15, 24 pageList : [5, 10, 15], 25 pageNumber : 1, 26 pagePosition : ‘bottom‘, 27 }); 28 29 });
三、php文件代码
1 <?php 2 //sleep(1); 3 header(‘Content-Type:text/html; charset=utf-8‘); 4 require ‘config.php‘; 5 $page = $_POST[‘page‘]; 6 $pageSize = $_POST[‘rows‘]; 7 $first = $pageSize * ($page - 1); 8 $biaoname="testeasyui_users"; 9 $biaoname="english"; 10 $query = mysql_query("SELECT * FROM ".$biaoname." LIMIT $first,$pageSize") or die(‘SQL 错误!‘); 11 $json = ‘‘; 12 while (!!$row = mysql_fetch_array($query, MYSQL_ASSOC)) { 13 $json .= json_encode($row).‘,‘; 14 } 15 $total = mysql_num_rows(mysql_query("SELECT * FROM ".$biaoname)); 16 $json = substr($json, 0, -1); 17 echo ‘{"total" : ‘.$total.‘, "rows" : [‘.$json.‘]}‘; 18 mysql_close(); 19 ?>
标签:
原文地址:http://www.cnblogs.com/qq2dfans/p/4448699.html