开发者

PHP: mysql_query INSERT INTO grab id?

开发者 https://www.devze.com 2023-01-11 14:59 出处:网络
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

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

精彩评论

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