jQuery UI Widgets › Forums › Grid › cannot work in ie9 but firefox and other well
Tagged: mysql update, php, php mysql
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 12 years, 11 months ago.
-
Author
-
jqwidgets-ver2.0\php_demos\server_side_grid_editing
WE ARE BUILDING IN APACHE+PHP+MYSQL WIN7
BUT NOW
IT CANNOT WORK IN IE9 MAXTHON
BUT OKAY IN FIREFOX GOOGLE CH AND APPLE SF
$(document).ready(function () {
// prepare the data
var data = {};
var theme = 'classic';var source =
{
datatype: "json",
datafields: [
{ name: 'idbytli'},
{ name: 'nabytli'},
{ name: 'ptbytli'},
{ name: 'otbytli'},
{ name: 'mbbytli'},
{ name: 'mdbytli'},
{ name: 'htbytli'},
{ name: 'email'}],
id: 'idbytli',
url: 'data.php',
updaterow: function (rowid, rowdata) {
// synchronize with the server - send update command
var data = "update=true&nabytli=" + rowdata.nabytli+ "&ptbytli=" + rowdata.ptbytli+ "&otbytli=" + rowdata.otbytli;
data = data +"&mbbytli=" +rowdata.mbbytli+"&mdbytli=" + rowdata.mdbytli+ "&htbytli=" + rowdata.htbytli+ "&email=" + rowdata.email;
data = data +"&idbytli=" +rowdata.idbytli;$.ajax({
dataType: 'json',
url: 'data.php',
data: data,
success: function (data, status, xhr) {
// update command is executed.
}
});
}
};
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 1078,
height: 400,
selectionmode: 'singlecell',
source: source,
theme: theme,
editable: true,
filterable: true,
autoheight: true,
pageable: true,
columns: [
{ text: 'ID号', editable: false, datafield: 'idbytli', width: 50 },
{ text: '姓名', columntype: 'dropdownlist', datafield: 'nabytli', width: 100 },
{ text: '所属处室', columntype: 'dropdownlist', datafield: 'ptbytli', width: 180 },
{ text: '办公电话', datafield: 'otbytli', width: 180 },
{ text: '手机号码', datafield: 'mbbytli', width: 180 },
{ text: '手机号码(地方虚拟网)', datafield: 'mdbytli', width: 190 },
{ text: '宅电', datafield: 'htbytli', width: 140 },
{ text: '邮箱', datafield: 'email', width: 180 }
]
});
});
DATA.PHP
$row['idbytli'],
'nabytli' => $row['nabytli'],
'ptbytli' => $row['ptbytli'],
'otbytli' => $row['otbytli'],
'mbbytli' => $row['mbbytli'],
'mdbytli' => $row['mdbytli'],
'htbytli' => $row['htbytli'],
'email' => $row['email']
);}
if (isset($_GET['filterscount']))
{
$filterscount = $_GET['filterscount'];if ($filterscount > 0)
{
$where = " WHERE (";
$tmpdatafield = "";
$tmpfilteroperator = "";
for ($i=0; $i < $filterscount; $i++)
{
// get the filter's value.
$filtervalue = $_GET["filtervalue" . $i];
// get the filter's condition.
$filtercondition = $_GET["filtercondition" . $i];
// get the filter's column.
$filterdatafield = $_GET["filterdatafield" . $i];
// get the filter's operator.
$filteroperator = $_GET["filteroperator" . $i];if ($tmpdatafield == "")
{
$tmpdatafield = $filterdatafield;
}
else if ($tmpdatafield $filterdatafield)
{
$where .= ")AND(";
}
else if ($tmpdatafield == $filterdatafield)
{
if ($tmpfilteroperator == 0)
{
$where .= " AND ";
}
else $where .= " OR ";
}// build the "WHERE" clause depending on the filter's condition, value and datafield.
switch($filtercondition)
{
case "CONTAINS":
$where .= " " . $filterdatafield . " LIKE '%" . $filtervalue ."%'";
break;
case "DOES_NOT_CONTAIN":
$where .= " " . $filterdatafield . " NOT LIKE '%" . $filtervalue ."%'";
break;
case "EQUAL":
$where .= " " . $filterdatafield . " = '" . $filtervalue ."'";
break;
case "NOT_EQUAL":
$where .= " " . $filterdatafield . " '" . $filtervalue ."'";
break;
case "GREATER_THAN":
$where .= " " . $filterdatafield . " > '" . $filtervalue ."'";
break;
case "LESS_THAN":
$where .= " " . $filterdatafield . " = '" . $filtervalue ."'";
break;
case "LESS_THAN_OR_EQUAL":
$where .= " " . $filterdatafield . " $row['idbytli'],
'nabytli' => $row['nabytli'],
'ptbytli' => $row['ptbytli'],
'otbytli' => $row['otbytli'],
'mbbytli' => $row['mbbytli'],
'mdbytli' => $row['mdbytli'],
'htbytli' => $row['htbytli'],
'email' => $row['email']);
}
echo json_encode($naminfo);
}
?>Hi louiszoom,
In order to make the MySQL UPDATE command to work with IE9, you will have to edit the data.php file. You will have to use the mysql_real_escape_string function when you get the parameters passed to the server.
For example:
if (isset($_GET['update'])){ // UPDATE COMMAND $update_query = "UPDATE employees SET `FirstName`='".mysql_real_escape_string($_GET['FirstName'])."', `LastName`='".mysql_real_escape_string($_GET['LastName'])."', `Title`='".mysql_real_escape_string($_GET['Title'])."', `Address`='".mysql_real_escape_string($_GET['Address'])."', `City`='".mysql_real_escape_string($_GET['City'])."', `Country`='".mysql_real_escape_string($_GET['Country'])."', `Notes`='".mysql_real_escape_string($_GET['Notes'])."' WHERE `EmployeeID`='".mysql_real_escape_string($_GET['EmployeeID'])."'"; echo $update_query; $result = mysql_query($update_query) or die("SQL Error 1: " . mysql_error()); echo $result;}
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.