Hi All,
I use edatagrid to updateUrl: (php file & update mysql), but not working.
Please help & tell me, what's wrong in staffupdatedata.php / staffrecord.html both file.
url: 'staffgetdata.php', <-- Sucess
saveUrl: 'staffsavedata.php', <-- Sucess
updateUrl: 'staffupdatedata.php', <-- not working & no change in database
destroyUrl: 'staffdestroydata.php' <-- Sucess
staffrecord.html
<title>Staff Record</title>
<link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<script type="text/javascript" src="plugins/jquery-1.7.2.js"></script>
<script type="text/javascript" src="plugins/jquery.easyui.min.js"></script>
<script type="text/javascript" src="plugins/jquery.edatagrid.js"></script>
<script type="text/javascript">
$(function(){
$('#frm_staffrec').edatagrid({
autoSave: true,
url: 'staffgetdata.php',
saveUrl: 'staffsavedata.php',
updateUrl: 'staffupdatedata.php',
destroyUrl: 'staffdestroydata.php'
});
});
</script>
</head>
<body>
<h1>Staff Record</h1>
<div id="toolbar">
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#frm_staffrec').edatagrid('addRow')">New</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#frm_staffrec').edatagrid('destroyRow')">Destroy</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#frm_staffrec').edatagrid('saveRow')">Save</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#frm_staffrec').edatagrid('cancelRow')">Cancel</a>
</div>
<table id="frm_staffrec" style="width:600px;height:600px" idField="dr_staffcode" url="staffgetdata.php"
toolbar="#toolbar" pagination="true" rownumbers="true" fitColumns="true"
title="Staff Data (double click to edit)" singleSelect="true">
<thead>
<tr>
<th field="dr_staffcode" width="100" editor="{type:'validatebox',options:{required:true}}">Staff Code</th>
<th field="dr_staffname" width="100" editor="{type:'validatebox',options:{required:true}}">Staff Name</th>
<th field="dr_stafflevel" width="80" editor="numberbox">Staff Level</th>
<th field="dr_staffemail" width="150" editor="{type:'validatebox',options:{required:true,validType:'email'}}">Email</th>
<th field="dr_staffactive" width="50" editor="numberbox">Active</th>
<!--
<th field="dr_staffcard" width="100" align="right" editor="{type:'numberbox',options:{precision:1}}">List Price</th>
<th field="unitcost" width="100" align="right" editor="numberbox">Unit Cost</th>
!-->
</tr>
</thead>
</table>
</body>
</html>
staffupdatedata.php
<?php
$id = $_REQUEST['id'];
$dr_staffcode = $_REQUEST['dr_staffcode'];
$dr_staffname = $_REQUEST['dr_staffname'];
$dr_stafflevel = $_REQUEST['dr_stafflevel'];
$dr_staffemail = $_REQUEST['dr_staffemail'];
$dr_staffactive = $_REQUEST['dr_staffactive'];
$dr_staffcarda = trim($_REQUEST['dr_staffcode']," ");
$dr_staffcard = $dr_staffcarda."0%T";
include 'mysqlconfig.php';
$sql = "update dr_staff set dr_staffcode=$dr_staffcode, dr_staffname=$dr_staffname, dr_stafflevel=$dr_stafflevel, dr_staffemail=$dr_staffemail, dr_staffactive=$dr_staffactive, dr_staffcard=$dr_staffcard where dr_staffcode='$id'";
@$db->query($sql);
echo json_encode(array(
'dr_staffcode' => $id,
'dr_staffname' => $dr_staffname,
'dr_stafflevel' => $dr_stafflevel,
'dr_staffemail' => $dr_staffemail,
'dr_staffactive' => $dr_staffactive
));
?>
staffgetdata.php
<?php
include 'mysqlconfig.php';
$myArray = array();
if ($result = $db->query("SELECT * FROM dr_staff")) {
$tempArray = array();
while($row = $result->fetch_object()) {
$tempArray = $row;
array_push($myArray, $tempArray);
}
echo json_encode($myArray);
}
$result->close();
$db->close();
?>