This topic is locked

Update a record in another table when inline edit is saved

5/17/2010 10:35:48 AM
PHPRunner General questions
S
sickacid author

Hi, i have to do this: "Update a record in another table when inline edit is saved"
TABLE1:id_first,field,field,field,id_second

TABLE2:id_second,field,field,field, free (as chekbox)
When i inlineedit the table one, i get a lookup list of table 2 linked

by id_second, when i select a line of table2 i want to update

the free field (in table 2) to set it as locked (1).
after in where clause i'll put display only id_second where free = 0, so

i can link only the free lines.
i put this code in list page, after record processed, but it isn't very nice...
global $conn;

$rs = db_query($str,$conn);

$i = $values["ID_id_Mappa"];

$strSQLInsert = "select * from magazzino_mappa where id_postomappa='".$i."'(ID_Link_IdArticolo) values ('1')";

db_exec($strSQLInsert,$conn);

A
ann 5/18/2010

Simone,
to update the second table after the first one is updated and assign free=1 at once use After record updated event on the Events tab of the first table.

Here is a sample:

global $conn;

$strSQLUpdate = "update TableName_2 set FieldName1_t1=".$values["FieldName1_t2"].",FieldName2_t1=".$values["FieldName2_t2"].",free=1 where id_second=".$values["id_second"];

db_exec($strSQLUpdate,$conn);

header("Location: TableName_2_edit.php?editid1=".$values["id_second"]);

exit();



where FieldName _t1 - is actual name of the field in first table, FieldName _t2 - is actual name of the field in the second table.