Data loaded from MySQL db without any id in my dhtmlxform

Hello,
Can someone tell me how I can I could work this around.

I use dhtmlxform to load some data from a table.
I actually just need to display this data (no need to edit)

Here’s an example of my data :
id => 1 // Primary Key and auto incremented value
datec => 2012-07-12 // Secondary Key and Unique
col1 => info1
col2 => info2

The default data should be displayed on page load depending the current day.

Here’s the line I use to init data load using dhtmlxconnector :
myForm.load(‘myfile.php?datec=’+date); // date is a calculated variable (it gives the current date formated Y-m-d)

Here’s my php file :
$res = mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);
$form = new FormConnector($res, “MySQL”);

$sql = "select datec, col1, col2 from mytable";
$sql.= " WHERE datec = '".$datec."'"; // datec is a $_GET variable 
$form->render_sql($sql, "id", "datec, col1, col2");

But, finally, on page load, I get this message error : “Uncaught exception ‘Exception’ with message ‘ID parameter is missed’ in…”;

I tested in adding an ID parameter :
myForm.load(‘myfile.php?id=1&datec=’+date);

and, in this case, it works…

Is this “ID” parameter really mandatory ? Or could you advise a way to work this around ?

Thanks for your help

Hello,

myForm.load(‘myfile.php?datec=’+date);

There should be also id parameter that define the id of the record that you want to load. For example:

myForm.load(‘myfile.php?datec=’+date+’&id=1’);

$sql = “select datec, col1, col2 from mytable”;

You should also select “id” field (the field that you defined in the second parameter of render_sql method):

$sql = “select id, datec, col1, col2 from mytable”;

Is this “ID” parameter really mandatory ?

Yes.

OK thank you !