RE: [PHP] return most current insert row id
| From: | Lawrence dot Sheed at dfait-maeci dot gc dot ca | Date: | Thu, 16 Nov 2000 02:16:41 +0000 |
| Subject: | RE: [PHP] return most current insert row id | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25583@lists.php.net to get a copy of this message | ||
Last inserted id?
If you're using Mysql:
The mysql way:
if ($result=mysql_query("select last_insert_id",$db)) {
$id = mysql_result($result,0);
}
Or
mysql_insert_id - a php function way
http://www.php.net/manual/function.mysql-insert-id.php
Cheers,
Lawrence.
-----Original Message-----
From: Rodino, Justin Bain [mailto:justin@goldendome.com]
Sent: November 16, 2000 10:07 AM
To: 'Maxim Maletsky'; 'Tom Beidler'; php-general@lists.php.net
Subject: RE: [PHP] return most current insert row id
select max(oid) as id from TABLE;
pending that it is postgreSQL.....
________________________________________
Justin Rodino <justin@goldendome.com>
Web Application Developer
Golden Dome Media
PO Box 1616
Notre Dame, IN 46634
219.631.1116
219.674.0980
800.728.7979
219.631.1001 - fax
http://www.goldendome.com/
http://www.wndu.com/
> -----Original Message-----
> From: Maxim Maletsky [mailto:maxim.maletsky@japaninc.net]
> Sent: Wednesday, November 15, 2000 9:03 PM
> To: 'Tom Beidler'; php-general@lists.php.net
> Subject: RE: [PHP] return most current insert row id
>
>
> SELECT * FROM table ORDER BY id DESC LIMIT 1;
>
> will select all from the last entry to the first and limit
> itself to 1 row.
>
> hope it is the answer you needed.
>
> Cheers,
> Maxim Maletsky,
>
> -----Original Message-----
> From: Tom Beidler [mailto:tbeidler1@home.com]
> Sent: Thursday, November 16, 2000 10:45 AM
> To: php-general@lists.php.net
> Subject: [PHP] return most current insert row id
>
>
> How can I return the a row id that was inserted in the same
> page/function?
>
> I have a page where I display what was added to the cart.
> When I display the
> information that was just inserted I would like to be able to
> make that same
> page a recalculation page. That way the end user can immediately make
> changes to the displayed info, ie. quantity.
>
> To recalculate I need the item_id of the row I just inserted.
>
> I just saw this in the mailing list but can't find anything
> in the archives
> and I haven't had luck searching the manual.
>
> Thanks,
> Tom
>
> >>.>>.>>>.>>>>>.>>>>>>>>>
> Tom Beidler
> Orbit Tech Services
> 805.455.7119 (cell)
> 805.682.8972 (phone)
> 805.682.5833 (fax)
> tbeidler@mindspring.com
> >>.>>.>>>.>>>>>.>>>>>>>>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net