I’m after a little help in the quest for cleaner code…
Current code which is working fine. Wondering if I can make it into one SQL statement as opposed to two…
$sql = "INSERT INTO table_a (1,2,3,4) VALUES ('$1','$2','$3','$4');";
$result = mysql_query($sql,$mysql_link);
$id = mysql_insert_id();
$sql2 = "INSERT INTO table_b (1,2,3,4) VALUES ('$id','$5','$6','$7');";
$result2 = mysql_query($sql2,$mysql_link);
How can I combine these two to work within my current php script?
Thanks!
An insert in two different tables is not possible.
If you want to reduce your query count you may have to reconsider your database structure.