For each grid load data from different table

Hello, newbie here trying to learn dhtmlx in combination with MySql.

I have tabbar with multiple tabs and each tab contains a grid and each grid needs to load data from a different table from the database.
I am using Gridconnector and Dataprocessor.

Is it common/possible to use the same .php file in the grid.load url and in that .php file declare multiple render_table statements in it for the grid’s, e.g. $conn->render_table(“tableA”), $conn->render_table(“tableB”), $conn->render_table(“tableC”).
And then for example use a switch statement in the .php file to select (depending on url parameter?) which render_table needs to be executed?

Thank you for your help.

Thank myself :slight_smile:
I tried some things myself and yes it is possible and working.

So this is solved.

The above scenario is a valid one. While only one connector triggered by a file call, there will be no problems.

Hello Stanislav, thank you for your reply.
I use the same $conn variable each time, is this what you recommend not to do?
So far this is working fine, see my (shortened) code below for client and server.

Client side 2 grid’s, same connector.php file:

gridA.init();
gridA.load("./data/connector.php?tbl=tableA");
var dp_gridA = new dataProcessor("./data/connector.php?tbl=tableA");
dp_gridA.init(gridA);


gridB.init();
gridB.load("./data/connector.php?tbl=tableB");
var dp_gridB = new dataProcessor("./data/connector.php?tbl=tableB");
dp_gridB.init(gridB);

Server side:

<?php $prmtr = $_GET["tbl"]; //get table parameter value from url require_once("../codebase/connector/grid_connector.php");//includes related connector file $res = mysql_connect("localhost","root",""); mysql_select_db("db"); $conn = new GridConnector($res,"MySQL"); switch ($prmtr) { case "tableA": $conn->render_table("tableA"); break; case "tableB": $conn->render_table("tableB"); break; default: //default code; } ?>

Sorry can’t answer your question, I am not familiar with phonegap, android, …