开发者

PHP: mysql_query INSERT INTO grab id?

so i have this: mysql_query("INSERT INTO..."); I was wondering after you've inserte开发者_Go百科d if you could echo out the id of the column you have inserted, or should i SELECT and that all around again?


You can use this function: mysql_insert_id() - Gets the ID generated in the last query

mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());

More info here

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜