代碼如下:
<html>
<head>
//搜索暫時沒做
<link rel="stylesheet" type="text/css" href="
<script type="text/javascript" src="
<script type="text/javascript" src="
<script type="text/javascript" src="
<script type="text/javascript" src="
<script type="text/javascript">
Ext
function test() {
Ext
}
function renderSex(value) {
if (value ==
return "<span style=
} else {
return "<span style=
}
}
function init()
{
//
var url =
var _proxy = new Ext
//
var _jsonProperty = "totalProperty";
//數據根目錄參數
var _jsonRoot = "root";
//Record顯示列表對應關系
var _record = [{name:
{name:
{name:
{name:
{name:
//創建JSONReader對象
var _reader = new Ext
/**
* 封裝一個客戶端的Record對象緩存
* 需要兩個必須的參數
*
*
*/
var _store = new Ext
proxy:_proxy
reader:_reader
});
/**
ColumnModel
* 數據在頁面上顯示標題信息
* 順序和Record對應
* sortable 是否排序
* dataIndex 進行對應的列
*
* handler方法中 第一個參數表示父類的對象
* 第二個參數表示第幾行
* 第三個參數表示第幾列
*/
var _cm = new Ext
new Ext
new Ext
{header:"ID"
{header:"用戶名"
{header:"密碼"
{header:"性別"
{header:"電子郵箱"
]);
/////////////////////////搜索
var logins = new Ext
id:
title:
width:
defaultType:
frame: true
// method:
collapsible: true
bodyPadding:
layout:
margin:
items: [{
fieldLabel:
labelWidth:
id:
}]
buttons: [{
// xtype:
text:
margin:
handler: search
}
// xtype:
text:
margin:
handler: hide
}]
renderTo: "search"
})
logins
function hide()
{
logins
}
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//獲取數據
var ds = new Ext
//proxy告訴我們從哪獲得數據
//proxy:new Ext
//通過http獲取數據
proxy:new Ext
url:url})
//獲取json數據
reader:new Ext
totalProperty:
root:
}
{name:
{name:
{name:
{name:
{name:
]))
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//自動分頁
var _pageSize =
var _toolbar = new Ext
store:ds
pageSize:_pageSize
displayInfo:true
displayMsg:
emptyMsg:
});
//頂部工具欄按鈕
var t_toolbar = [
{id:"addData"
{id:"updateData"
{id:"deleteData"
{id:"test"
{id:"search"
];
/**
* GridPanel對象
* 數據列表頁面
* 必須設置 Store 數據訪問對象和標題欄顯示信息
* 即 Store和ColumnModel對象
*/
var _grid = new Ext
headerAsText: false
collapsible: true
height:
width:
frame:true
store:ds
title:
cm:_cm
bbar : _toolbar
tbar : t_toolbar
});
ds
_grid
//_grid
/* 用戶信息錄入框
var fpanel;
function f(){
fpanel = new Ext
({
frame : true
labelAlign :
waitMsgTarget : true
autoScroll : true
buttonAlign :
items : [
{xtype:"hidden"
{xtype:"textfield"
blankText:"用戶名不允許為空!"
{xtype:"radiogroup"
{xtype:"textfield"
blankText:"密碼不允許為空!"
{xtype:"textarea"
blankText:"郵箱不允許為空!"
]
});
}
var win;
/* 增加用戶 */
function addUser()
{
f();
win = new Ext
({
title:"新增用戶"
id:"win"
//animEl:"fly"
//layout:"fit"
width:
height:
closeAction : "close"
plain : true
modal : true
bodyStyle:"padding:
layout:"form"
labelWidth:
items:[fpanel]
buttons:[
{text:"保存"
{
//在保存的時候
//在後台處理的時候
fpanel
fpanel
url : "add
method : "POST"
waitMsg : "保存數據
success : function(form
// 業務成功
Ext
win
ds
}
failure : function(form
// 業務失敗
obj = Ext
Ext
win
ds
}
});
}
}
{
text:"重置"
{
fpanel
}
}
]
})
win
// 因為重復使用window
fpanel
}
/* 修改用戶信息 */
function updateUser()
{
var win_
var a =
f();
var selectedRecord = _grid
// 獲得多個數據
if (selectedRecord == undefined || selectedRecord == null)
{
Ext
} else {
win_
({
title : "修改用戶"
width :
height :
closeAction : "hide"
plain : true
modal : true
bodyStyle : "padding:
//layout : "form"
layout:"fit"
labelWidth :
items : [fpanel]
buttons : [
{text:"修改"
{fpanel
({
url:"edit
method:"POST"
waitMsg:"數據修改中
success:function(form
{
win_
Ext
_ds
}
failure : function(form
win_
Ext
_ds
}
});
}
}
{
text : "重置"
{
fpanel
}
}
{
text:
{
win_
}
}
]
});
}
win_
// 將選中的數據load到window中顯示
//alert(win_
win_
}
/* 刪除用戶 */
function removeUser(btn)
{
var selectedRecord = _grid
if (selectedRecord == undefined || selectedRecord == null)
{
Ext
} else {
Ext
{
if (btn == "yes")
{
Ext
{
url:"del
method:"POST"
params:{id : selectedRecord
success:function(request
{
var jsonRequest = Ext
if (jsonRequest == true)
{
Ext
_grid
ds
} else {
Ext
}
}
failure : function()
{
Ext
({
title : "提示消息"
msg : "刪除時發生錯誤"
});
}
});
}
})
}
}
function chkSelects()
{
var selects = _grid
alert("選中的總數為
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function search(){
//fpanel
logins
//clientValidation: true
method:"POST"
url:"search
waitMsg:"請稍等
waitTitle:"正在搜索"
});
var url =
// store
ds
//_proxy = new Ext
//ds
//_grid
}
function jump()
{
logins
}
//////////////////////////////
}
Ext
</script>
</head>
<body>
<p style="height:
<div id="test_id"></div>
<div id="search"></div>
</body>
</html>
Index
<?php
header("Content:text/html;charset=utf
$link = mysql_connect("localhost"
mysql_select_db("stu"
mysql_query(
$sql = "select count(*) num from men";
$num = mysql_query($sql);
$count = mysql_fetch_array($num);
$start = $_POST[
$limit = $_POST[
$sql
/*
if (!$_POST)
{
$sql
} else {
$sql
}
*/
$data = array();
$result = mysql_query($sql
while(!!$info = mysql_fetch_array($result
{
$data[] = $info;
}
//$j = json_encode($data);
$j = "{totalProperty:
echo $j;
?>
Add
<?php
header("Content:text/html;charset=utf
$link = mysql_connect("localhost"
mysql_select_db("stu"
mysql_query(
$name = $_POST[
$pwd = $_POST[
$time = $_POST[
$email = $_POST[
/*
$name =
$pwd =
$time =
$email =
$sql = "INSERT INTO men (username
//mysql_query($sql)
if (mysql_query($sql))
{
echo
}
?>
Del
<?php
header("Content:text/html;charset=utf
$link = mysql_connect("localhost"
mysql_select_db("stu"
mysql_query(
$id = $_POST[
$sql = "DELETE FROM men WHERE id={$id}";
if (mysql_query($sql))
{
echo
} else {
echo
}
?>
數據庫文件men
數據庫名叫
表名為
可以把下面的復制到一個文本文檔裡
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE `men` (
`id` int(
`name` varchar(
`pass` varchar(
`sex` varchar(
`email` varchar(
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf
INSERT INTO `men` (`id`
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
From:http://tw.wingwit.com/Article/program/PHP/201311/21009.html