<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学习平台</title>
<link href="__PUBLIC__/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/themes/icon.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery.easyui.min.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<h1>DataGrid</h1>
<table id="dg" title="My Users" class="easyui-datagrid" style="width:700px;height:250px"
url="{:U('Index/index')}"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="subjectcode" width="50">subjectcode</th>
<th field="question" width="250">Question</th>
</tr>
</thead>
</table>
</body>
</html>use Think\Controller;
class IndexController extends Controller {
public function index(){
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;
$qq =M('questions')->field('subjectcode,question')->limit("$offset,$rows")->select();
$qty= count(M('questions')->select());
$result["total"] = $qty;
$result["rows"] = $qq;
echo json_encode($result);
$this->display();
}
} 最佳答案