HI Abu, made a post regarding this but cannot find it now so hope you don't mind if I post again?
After you kindly demoed how to insert data into two tables I found I couldn't then update the grid, it would take the data but lose on refresh. I added an update function but this doesn't allow edit/update either, can you spot where I am going wrong if you have time?
Many thanks
Gary
The update query has different syntax. I've updated link.
Added client_id & gender hidden column to update first table.
Diff: http://www.mergely.com/bTaJctVF/ (set options > ignore white space … to see exact differences)
Try printing sql inside function and check if it is correct. It will display the query in error popup.
$sql = "update ….. ";
phpgrid_error($sql);
By code i think it should be:
WHERE id = '{$data[params][id]}'
(as your second table primary key is id)
You can always email me grid code + db sql dump to verify changes.
Thanks Abu, that is fantastic, works lovely on the demo, on my own grid though it will now only update the 1 table, tbl_clients. tbl_lead wont update, I think I have gone through every bit of the demo code to ensure its correct yet still it wont update?
Will key trying to resolve but can you spot where the issue may be? I have a feeling its in the tbl_lead WHERE clause in update function but have tried many things?
Thank you, hopefully this will be last question for now 🙂
Hi Abu, sorry another update but I have sort of fixed it, I had the where statement wrong but it will only update when you use inline editing..If I select row and choose edit from bottom menu it says record updated but doesn't update it!
Changing comms = '{$data[params][comms]}'WHERE id = '{$data[id]}'");
to
comms = '{$data[params][comms]}' WHERE client_id = '{$data[params][client_id]}'");
Thank you again
Hi Abu, have tried that statement and a few others, have sent you db & php via email.
Kind Regards
Gary
I've emailed you the fix.
You need to make first column as 'editable' => true.
$col = array();
$col["title"] = "client_id"; // caption of column
$col["name"] = "client_id"; // grid column name
$col["editable"] = true; // <<<<<<<<<<<<<<<<<<<<<<<<<<<
$col["hidden"] = true; // hide on grid
$col["width"] = "10";
$cols[] = $col;
Will not be displayed but submitted.
Hi Abu, thank you again, that seems to have worked but oddly enough only when I set the 1st tables primary key value..
I think it should be WHERE id = '{$data[params][id]}' but that doesn't allow update, changing to WHERE client_id = '{$data[params][client_id]}' does allow so will do further testing to see if this affects tables anywhere else.
Thanks again
Gary
Change 1: Move id column as first column.
$col = array();
$col["title"] = "id"; // caption of column
$col["name"] = "id"; // grid column name
$col["editable"] = true;
$col["hidden"] = true; // hide on grid
$col["width"] = "10";
$cols[] = $col;
// caption of column
$col = array();
$col["title"] = "client_id"; // caption of column
$col["name"] = "client_id"; // grid column name
$col["editable"] = true;
$col["hidden"] = true; // hide on grid
$col["width"] = "10";
$cols[] = $col;
Change 2: for leads table … set: WHERE id = '{$data[params][id]}'");
Emailing you updated file.