DHTMLX Grid with php

I have created a DHTMLX Grid with DHTMLX Connector and Data Processor. I have used the rendertable code fine to connect with my database and show the content of a given table in my grid. I am now wondering how to create a more complex grid where I use information from various tables in my database… where clauses… and maybe even the returning of information based on the member that views the grid… via sessions or cookies.

Do you all have any demos or demo code of this type of thing? I have not seen any on your site anywhere… please direct me to it if it is available. Or if not, please let me know if you have such an example that you can send to me.

Thanks, I do have your FULL / Enterprise Suite!
Wayne & Lori

The simplest way - continue to use connector, and use render_sql instead of render_table - inside render_sql you may have joined tables, where clause, external vars - all kind of logic is possible.

docs.dhtmlx.com/doku.php?id=dhtm … operations

Please Help!

I get the ‘Incorrect XML’ dialog popup after updating a record. I use the same query for populating a grid as I do when populating the grid. I have no problem loading the grid data.

When populating the grid (works) - server side carriers_connector.php script: require(”./dhtmlx/dhtmlxConnector/codebase/grid_connector.php”); $res=mysql_connect(“localhost”,”root”,”mypassword”); mysql_select_db(“TM”); $grid = new GridConnector($res,”MySQL”); $grid→render_sql(“SELECT ID,NAME,CODE,URL,STATUS_FK,‘Web’ AS LINK FROM CARRIER”, “ID”,”ID,NAME,CODE,URL,STATUS_FK,LINK”,”LINK”,””);

My server side php update script (carriers_update.php) based on your examples posts the xml error:

$res=mysql_connect(“localhost”,”root”,”mypassword”); mysql_select_db(“TM”); require(‘dhtmlx/dhtmlxConnector/codebase/grid_connector.php’); $grid = new GridConnector($res,”MySQL”); $grid→enable_log(“temp.log”,true); $grid→sql→attach(“Update”,”Update CARRIER set NAME=’{NAME}’, CODE=’{CODE}’, URL=’{URL}’, STATUS_FK={STATUS_FK} WHERE ID={ID}”); $grid→render_sql(“SELECT ID,NAME,CODE,URL,STATUS_FK,‘Web’ AS LINK FROM CARRIER”, “ID”,”ID,NAME,CODE,URL,STATUS_FK,LINK”,”LINK”,””);

Quite frankly, I am a bit surprised that I need to use render_sql after a simple update procedure. Why should you need to resend updated table data to a grid that already has the data in the first place.

This is my boiled down client script (I am not showing the includes here but they are there): var grid = win.attachGrid(); grid.setImagePath(“dhtmlx/dhtmlxGrid/codebase/imgs/”); grid.setHeader(“ID,Name,Code,URL,Status,Website”); grid.setColumnIds(“ID,NAME,CODE,URL,STATUS_FK,WEBSITE”); grid.setInitWidths(“50,150,50,*,60,60”); grid.setColAlign(“right”); grid.setColTypes(“ro,ed,ed,ed,coro,button”); grid.enableEditEvents(true, true, true); grid.setColSorting(“int, str”); grid.getCombo(4).put(0, ‘disable’); grid.getCombo(4).put(1, ‘one’); grid.getCombo(4).put(2, ‘two’); grid.setSkin(“dhx_skyblue”); grid.init(); grid.load(“http://localhost/rms/carriers_connector.php”); dataProcessor = new dataProcessor(“http://localhost/rms/carriers_update.php”); dataProcessor.enableDataNames(true); dataProcessor.setDataColumns([false,true,true,true,true,false]); dataProcessor.init(grid);

When I change the update script (carriers_update.php) to something like the following it works, but only for one update per record. In other words, if I edit one cell it updates properly, but will not update the second cell of the same record.

header(‘Content-Type: text/xml’); $res=mysql_connect(“localhost”,”root”,”mypassword”); mysql_select_db(“TM”); if ($nativeeditor_status==‘updated’) {

$STATUS_FK = intval($STATUS_FK);
$ID = intval($ID);
if ($URL==’’) $URL=“NULL”;
else $URL = “’$URL’”;
$sql = “UPDATE CARRIER SET NAME=’$NAME’, CODE=’$CODE’, URL=$URL, STATUS_FK=$STATUS_FK WHERE ID=$ID;”;
$rs = mysql_query($sql,$res);

} echo ‘<?xml version=“1.0” encoding=“ISO-8859-1”?>’;

What might help quite a bit is seeing your update.php script (which works quite fine) as it is being used in: dhtmlx.com/docs/products/dht … _init.html

Thanks for your help.