0

I'm using the following code to add a entry to my SQL database.

$RQ1_string = "INSERT INTO automotive_RQ01_Information VALUES(NULL,'".$title."','".$description."')";
$RQ1_result = mysql_query($RQ1_string);

In the next line I need to use the value of the auto-incrementing ID(The NULL entry).

How can I get the ID from RQ1_result?

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225

1 Answers1

1

You would use mysql_insert_id(). This can be assigned to a variable or outputted directly.

http://www.php.net/manual/en/function.mysql-insert-id.php

James Williams
  • 4,221
  • 1
  • 19
  • 35