Master Detail examples for MySql database with 2 tables


#1

Is this supported in ver. 4 ??
Can’t se any examples in the standard version 4 which i downloaded.
I am trying to display 2 grids with master detail relationship.
The data is loaded from MysQl (from server).
The database name is: CustOrder
There are two tabels in the database: Customers and Orders
The first grid loads table (Customers) with fileds: CustNum and CustName
The second grid loads table (Orders) in the detail grid with fields: OCustNum , OrderNum and Orderdetails.
I have this working up to some extend but I can’t get the selected customer from Customers
table to show up in the details(Orders) Grid. Tried various filtermethods.
Filter: CustNum = OCustnum.
Been looking hard for examples in ver. 4 but can’t find it (loading data from 2 different tables
from the same database (CustOrder) (MySql)).
Any examples around for this ?


#2

I don’t think that suite has such a sample, but it requires just a few lines of code
On client side

grida.attachEvent("onRowSelect", function(id){ gridb.clearAll(); gridb.load("datab.php?for="+id); })

and on server side in datab.php you need to use something like next

$gridb->render_sql("select * from tableB where customer="+$_GET["from"],"id","fields....");

#3

Stanislav - thanks for this imput.
I will test this


#4

Can’t figure out what is wrong with this code - long list of errors

$gridb->render_sql(“select * from tableB where customer=”+$_GET[“from”],“id”,“name”);

Regards


#5

Sorry, was a my typo, the valid code will be

$gridb->render_sql("select * from tableB where customer=".$_GET["from"],"id","name");

using .$_GET instead of +$_GET


#6

That did not work either - the “from” in the Get[] was erroring.
However I defined folloving in server side:

$id = mysql_real_escape_string($_GET[‘id’]);
Then I used:
$gridb->render_sql("SELECT * from tableB where Customer = ‘$id’ ",“Name”);

This works !

Many thanks for you input