This is the index.php, get.php, update.php.
get.php works fine, but when editing the column parameter are null and nothing happens.
index.php
[code]
Untitled Document
[/code]
get.php
[code]<?php
//require("…/dhtmlx/codebase/grid_connector.php");
$res = mysql_connect(“127.0.0.1”,“ba_user”,“b4_us3r!”);
mysql_select_db(“banjodb”);
/*
$gridConn = new GridConnector($res,“MySQL”);
$gridConn->render_table(“t_list_asset_type”, “id_asset_type”, “asset_type, id_user”);
*/
//include XML Header (as response will be in xml format)
header(“Content-type: text/xml”);
//encoding may be different in your case
echo(’<?xml version="1.0" encoding="utf-8"?>’);
//start output of data
echo ‘’;
//output data from DB as XML
$sql = “SELECT asset_type, id_asset_type FROM t_list_asset_type”;
$res = mysql_query ($sql);
if($res){
while($row=mysql_fetch_array($res)){
//create xml tag for grid’s row
echo ("<row id=’".$row[‘id_asset_type’]."’>");
print("");
print("");
}
}else{
//error occurs
echo mysql_errno().": “.mysql_error().” at “.LINE.” line in “.FILE.” file
";
}
echo ‘’;
?>
[/code]
update.php
[code]<?php
//code below is simplified - in real app you will want to have some kins session based autorization and input value checking
//require_once $_SERVER[‘DOCUMENT_ROOT’].’/banjo/connector/grid_connector.php’;
$res = mysql_connect(“127.0.0.1”,“ba_user”,“b4_us3r!”);
mysql_select_db(“banjodb”);
function add_row(){
global $newId;
$sql = "INSERT INTO t_list_asset_type (asset_type, id_user)
VALUES ('".addslashes($_GET["c0"])."',1)";
$res = mysql_query($sql);
//set value to use in response
$newId = mysql_insert_id();
return "insert";
}
function update_row(){
$sql = “UPDATE t_list_asset_type SET asset_type = '”.addslashes($_GET[“c0”])."’ WHERE id_asset_type = ".$_GET[“gr_id”];
$res = mysql_query($sql);
return "update";
}
function delete_row(){
$d_sql = "DELETE FROM t_list_asset_type WHERE id_asset_type = ".$_GET["gr_id"];
$resDel = mysql_query($d_sql);
return "delete";
}
//include XML Header (as response will be in xml format)
header(“Content-type: text/xml”);
//encoding may differ in your case
echo(’<?xml version="1.0" encoding="iso-8859-1"?>’);
$mode = $_GET["!nativeeditor_status"]; //get request mode
$rowId = $_GET[“gr_id”]; //id or row which was updated
$newId = $_GET[“gr_id”]; //will be used for insert operation
switch($mode){
case “inserted”:
//row adding request
$action = add_row();
break;
case “deleted”:
//row deleting request
$action = delete_row();
break;
case “updated”:
//row updating request
$action = update_row();
break;
}
//output update results
echo “”;
echo “”;
echo “”;
?>[/code]