qinsilandiao

本章我们开始进行后台管理界面的设计,本节主要操作管理员模块。
一.L HTML 部分
//非管理员登录跳转
<?php
session_start();
if (!isset($_SESSION[\'admin\'])) {
header(\'location:login.php\');
}
?>
//管理员模块的 DataGrid 数据表
<table id="manage"></table>
//管理员模块的工具栏
<div id="manage_tool" style="padding:5px;">
<div style="margin-bottom:5px;">
<a href="#" class="easyui-linkbutton" iconCls="icon-add-new"
plain="true" onclick="manage_tool.add();">添加</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-edit-new"
plain="true" onclick="manage_tool.edit();">修改</a>
<a href="#" class="easyui-linkbutton"
iconCls="icon-delete-new" plain="true" onclick="manage_tool.remove();">
删除</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-reload"
plain="true" onclick="manage_tool.reload();">刷新</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-redo"
plain="true" id="redo" onclick="manage_tool.redo();">取消选择</a>
</div>
<div style="padding:0 0 0 7px;color:#333;">
查询管理员:<input type="text" class="textbox"
name="search_manager" style="width:110px">

创建时间从:<input type="text" name="date_from"
class="easyui-datebox" editable="false" style="width:110px">
到:<input type="text" name="date_to" class="easyui-datebox"
editable="false" style="width:110px">
<a href="#" class="easyui-linkbutton" iconCls="icon-search"
onclick="manage_tool.search();">查询</a>
</div>
</div>
//管理员模块的 JS 文件
<script type="text/javascript" src="js/manager.js"></script>

 

二.y jQuery 部分
//DataGrid 数据表格
$(\'#manage\').datagrid({
url : \'manager_data.php\',
fit : true,
fitColumns : true,
striped : true,
rownumbers : true,
border : false,
pagination : true,
pageSize : 20,
pageList : [10, 20, 30, 40, 50],
pageNumber : 1,
sortName : \'date\',
sortOrder : \'desc\',
toolbar : \'#manage_tool\',
columns : [[
{
field : \'id\',
title : \'自动编号\',
width : 100,
checkbox : true,
},
{
field : \'manager\',
title : \'管理员帐号\',
width : 100,
},
{
field : \'auth\',
title : \'拥有权限\',

width : 100,
},
{
field : \'date\',
title : \'创建时间\',
width : 100,
},
]],
});

 

三.P PHP 部分
<?php
require \'config.php\';
$page = $_POST[\'page\'];
$pageSize = $_POST[\'rows\'];
$first = $pageSize * ($page - 1);
$order = $_POST[\'order\'];
$sort = $_POST[\'sort\'];
$query = mysql_query("SELECT id,manager,auth,date FROM easyui_admin
ORDER BY $sort $order LIMIT $first,$pageSize") or die(\'SQL 错误!\');
$total = mysql_num_rows(mysql_query("SELECT id,manager,auth,date
FROM easyui_admin"));
$json = \'\';
while (!!$row = mysql_fetch_array($query, MYSQL_ASSOC)) {
$json .= json_encode($row).\',\';
}
$json = substr($json, 0, -1);
echo \'{"total" : \'.$total.\', "rows" : [\'.$json.\']}\';
mysql_close();
?>

 

分类:

技术点:

相关文章: