whatever the primary key # of the last insert query
performed.
This help at all?
From: Niklas Lampén [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Php-General [EMAIL PROTECTED]
Subject: RE: [PHP] Getting the last record in a mysql table FINALLY!!
Date: Fri, 18 Jan 2002 10:05:35 +0200
Well
Help!
I thought this would be easy but it ain't. What I want is the id number of the last
record in a table. I've tried a number of variations to the following but am getting
no where! Any help will be greatly appreciated.
Hugh
$results=mysql_query( SELECT last_insert_id() FROM MY_TABLE );
I thought this would be easy but it ain't. What I want is
the id number of the last record in a table.
If you use mysql_num_rows() and decrement it by one, you'll
have the ID of the row you can use with mysql_result.
Jason
--
PHP General Mailing List (http://www.php.net/)
To
danaher' [EMAIL PROTECTED]; Php-General
[EMAIL PROTECTED]
Sent: Thursday, January 17, 2002 9:40 PM
Subject: RE: [PHP] Getting the last record in a mysql table
I thought this would be easy but it ain't. What I want is
the id number of the last record in a table.
If you use mysql_num_rows
You're welcome.
Heh, why to make too hard. :)
Niklas
-Original Message-
From: hugh danaher [mailto:[EMAIL PROTECTED]]
Sent: 18. tammikuuta 2002 8:40
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Getting the last record in a mysql table
Niklas,
Now that sounds like a solution!
Thanks
(biggest) ID number.
Niklas
-Original Message-
From: hugh danaher [mailto:[EMAIL PROTECTED]]
Sent: 18. tammikuuta 2002 7:37
To: Php-General
Subject: [PHP] Getting the last record in a mysql table
Help!
I thought this would be easy but it ain't. What I want is the id number
of the last
[EMAIL PROTECTED]
Sent: Thursday, January 17, 2002 10:29 PM
Subject: RE: [PHP] Getting the last record in a mysql table
If you have ID that is a incrementing number, you could just query like
this:
'SELECT ID FROM MY_TABLE ORDER BY ID DESC, LIMIT 1'
And there you have just one result
Well, ofcourse you have to have the table + field names right. ;)
Niklas
-Original Message-
From: hugh danaher [mailto:[EMAIL PROTECTED]]
Sent: 18. tammikuuta 2002 9:38
To: [EMAIL PROTECTED]
Cc: Php-General
Subject: Re: [PHP] Getting the last record in a mysql table FINALLY
8 matches
Mail list logo