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
精彩评论