Re: mySQL getting primary key of the last added record
| From: | Doug Semig | Date: | Wed, 22 Nov 2000 05:18:04 +0000 |
| Subject: | Re: mySQL getting primary key of the last added record | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4636@lists.php.net to get a copy of this message | ||
You want mysql_insert_id(). But you'll have to have the script that does
the actual INSERT call this function and pass the value to the redirected
page either via the session mechanisms or as part of the URL
(inserted.phtml?rowid=12982 or whatever).
Doug
At 10:38 PM 11/21/00 -0500, jeff marston wrote:
>Here's my problem:
> I'm trying to insert a record into a table, then redirect to a page that
>shows information about that record. I do the INSERT INTO tblname VALUES
>(...), and let mySQL assign an auto_incrementing primary key ID field. Does
>php have a function (like mysql_affected_rows(), I guess) that can tell you
>about the last record that was inserted? Or maybe it's in mySQL -- I've
>done something like this with SQL Server 7. Or maybe there's an easy
>workaround that I'm missing.
>
>Any help? Thanks!
>
>// jeff