mysql_query("INSERT INTO table1 ('colums') VALUES ('columns')");
$id = mysql_insert_id();
mysql_query("INSERT INTO TABLE2 ('column') VALUES ('$id')");
หรือ
mysql_query("INSERT INTO table1 ('colums') VALUES ('columns')");
$id = mysql_query("SELECT id FROM table1 ORDER BY id DESC LIMIT 1 ");
mysql_query("INSERT INTO TABLE2 ('column') VALUES ('$id')");