Hi,
Currently i have 3 Tables - A, B and C. All 3 tables have their unique IDs (which are auto increment) and Table B and C are a foreign keys to Table A.
says:
Table A = A_id, A_fname, B_id, C_id
Table B = B_id, B_add, B_pcode
Table C = C_id, C_state
My application is set up with a form to insert records of a persons name, their address, postal codes and state simultaneously into these three tables.
my code is like this:
$B_insert = "INSERT INTO B (B_add, B_pcode)
VALUES ('$val_add', '$val_pcode')";
$result = mysql_query($B_insert) or die (mysql_error());
$C_insert = "INSERT INTO C (C_state)
VALUES ('$val_state')";
$result = mysql_query($C_insert) or die (mysql_error());
$A_insert = "INSERT INTO A (A_fname, B_id, C_id)
VALUES ('$val_fname', 'mysql_insert_id()', 'mysql_insert_id ()')";
$result = mysql_query($A_insert) or die (mysql_error());
When i checked on my display table, the foreign keys to Table A for Table B and C return the value '0'.
Anyone can help me?? thanks