Click to See Complete Forum and Search --> : Small PHP question


ava
11-18-2005, 07:32 AM
I have a table with an autonumber field called Token. Now after I input a record in that table I need the token value of the record I just added. Is there a way to do that without running a new query to search it?

Cipher
11-18-2005, 07:48 AM
well i'm not php prof, but i have some exp in php, so i dont think there's a way to do that, i think you have to do one of two things
to select "MAX(Token)" before you add new item to it and assign it to variable for instance "TokenID", then in your script increase the value by 1 of that variable "TokenID++;".
the second way is to select "MAX(Token)" after you add new item and also assign it to variable :)
Hope this helps;

chazzy
11-18-2005, 10:16 AM
If you're using a mysql backend, there is the mysql_insert_id http://us2.php.net/manual/en/function.mysql-insert-id.php
but this is platform dependent.