复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<meta content="jquery,ui,easy,easyui,web"> 
<meta content="easyui help you build your web page easily!"> 
<title>一條小龍 easyUI datagrid</title> 
<link type="text/css" href="./JS/EasyUI/themes/default/easyui.css"> 
<link type="text/css" href="./JS/EasyUI/themes/icon.css"> 
<script type="text/javascript" src="./JS/jquery.js"></script> 
<script type="text/javascript" src="./JS/EasyUI/jquery.easyui.min.js"></script> 
</head> 
<body> 
<h2>一條小龍 easyUI datagrid url test</h2> 
<table 
url="datagrid2_getdata.php" pagination="true"> 
<thead> 
<tr> 
<th field="UNum">UNum</th> 
<th field="STUID">User ID</th> 
<th field="Password">Password</th> 
<th field="Birthday">Birthday</th> 
<th field="Nickname">Nickname</th> 
<th field="DBSTS">DBSTS</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(); 
$tablename = "STUser"; 
// ... 
require_once("./db/DB_config.php"); 
require_once("./db/DB_class.php"); 
$db = new DB(); 
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']); 
$db->query("select count(*) As Total from $tablename"); 
$row = $db->fetch_assoc(); 
$result["total"] = $row["Total"]; 
$db->query("select * from $tablename limit $offset,$rows"); 
$items = array(); 
while($row = $db->fetch_assoc()){ 
array_push($items, $row); 
} 
$result["rows"] = $items; 
echo json_encode($result); 
?>
新闻热点
疑难解答