This topic is locked

Adding parent to multiple children

10/4/2007 2:54:46 PM
PHPRunner General questions
M
mrpeeble author

I'm trying to insert to multiple children table from one parent table.

I am able to use After Add and the following code for 1 parent and 1 child table, but having difficulty with 1 parent and multiple children.

Below is my code:
global $conn;

{

$id = mysql_insert_id();

{

$strSQLInsert = "insert into stf_staffdetails (StaffID,SeniorityDate,SeniorityHours,OfficeSeniorityDate,MyStatus,MyPosition, Address,ApartmentNumber,City,PostalCode,Telephone,SecurityAccessNumber) values (".$id.", '".$values["SeniorityDate"]."', '".$values["SeniorityHours"]."', '".$values["OfficeSeniorityDate"]."', '".$values["MyStatus"]."', '".$values["MyPosition"]."', '".$values["Address"]."', '".$values["ApartmentNumber"]."', '".$values["City"]."', '".$values["PostalCode"]."', '".$values["Telephone"]."', '".$values["SecurityAccessNumber"]."')";

$strSQLInsert1= "insert into stf_contact (StaffID,EmergencyContactName,ContactPhone,AlternateContactName,AlternateContact

Phone, Relationship) values (".$id.", '".$values["EmergencyContactName "]."', '".$values["ContactPhone "]."', '".$values["AlternateContactName "]."', '".$values["AlternateContactPhone "]."', '".$values["Relationship "]."')";

$strSQLInsert2= "insert into stf_parking (StaffID,PlateNumber,PlateNumber2,BluePassNumber,GatePass, VehicleMake) values (".$id.", '".$values["PlateNumber "]."', '".$values["PlateNumber2 "]."', '".$values["BluePassNumber "]."', '".$values[",GatePass "]."', '".$values["VehicleMake "]."')";
db_exec($strSQLInsert,$conn);

db_exec($strSQLInsert1,$conn);

db_exec($strSQLInsert2,$conn);
}

}


Thanks for your help.

Alexey admin 10/5/2007

Hi,
looks like some your field names are typed wrong.

With trailing spaces:

$values["BluePassNumber "]



and commas:

$values[",GatePass "]


Fix these error first.

If this doesn't help you can publish your app on Demo Account and send a link to it with a problem description to support@xlinesoft.com

M
mrpeeble author 10/5/2007

can't believe i missed that <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=21958&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />

thanks Alexey!