Re: Adding Records & Capture The New Record ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/2/7 revDAVE <Cool@xxxxxxxxxxxxxxxx>:
> Adding records & capture the new record ID:
>
> In the past, if I added a new record from a form in a phonebook file as an
> example,  I would use a web form to fill out the info,  and then add and
> invisible text item that stored a random number in one of the unused
> database fields.
>
> Then, after I inserted the record -  I would do a quick query that would
> retrieve the record ID by searching for the random number

Ouch that's nasty!!

> Q: is there a better way to retrieve the record ID from the newly added
> record?

Use an auto_increment field then, assuming MySQL you can use
mysql_insert_id to get the ID of the last record inserted on a given
connection.

-Stuart

-- 
http://stut.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux