开发者

Add an item to SQL and get auto incrementing id back immediately

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜