[thelist] mysql/php: get auto-increment ID for record

Jon Haworth jhaworth at witanjardine.co.uk
Thu Feb 27 09:31:40 CST 2003


Hi Aleem,

> // get the last ID from above query:
> $query="SELECT * FROM firstTable ORDER BY id DESC LIMIT 1";

PHP provides a function for exactly this situation:
http://php.net/mysql-insert-id

HTH
Jon



More information about the thelist mailing list