I am not sure if this in in the correct area or not. I am trying to do an insert statement into two tables. Table one is the parent and has an auto increment field as the key. The child table is suppose to get the key from the parent by using last_insert_id and insert into the child table. But, the child table as it's own auto increment field. So, using the last_insert_id function returns the id of the wrong field. I understand why it's not working, because the last id entered is the question_id field. Do I have to drop the table and rearrange the quiz_id and question_id fields?
Did I construct the table wrong for this or is there a way around it?
//Insert Quiz information into database $query = "INSERT INTO `question` (`quiz_id`,`question_id`, `question`, `a`, `b`, `c`, `d`, `key`)" . // Not entering the correct quiz_id "VALUES ( last_insert_id(), NULL, '$q', '$a', '$b', '$c', '$d', '$key')";
Did I construct the table wrong for this or is there a way around it?