Get current AUTO_INCREMENT value – MySQL query
Solution is simple, use mysql_insert_id() php function.
mysql_insert_id() returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. Use this function after you have performed an INSERT statement into a table that contains an AUTO_INCREMENT field, or have used INSERT / UPDATE to set a column value with LAST_INSERT_ID(expr).
mysql_insert_id() returns 0 (zero) if the previous statement does not use an AUTO_INCREMENT value. If you need to save the value for later, be sure to call mysql_insert_id() immediately after the statement that generates the value – like: mysql_query($query) .
Categories: MySQL, PhP, Tech AUTO_INCREMENT, Get Next Auto_increment, MySQL, MySQL query, mysql_insert_id, PhP, programming








