his should print out 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
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
TED]>
To: Php-General <[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, LIMI
Another option under same condition is:
'SELECT MAX(ID) AS LASTID FROM MY_TABLE'
Alex Chau
Niklas Lampén wrote:
>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, the last (
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!
T
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, the last (biggest) ID number.
Niklas
-Original Message-
From: hugh danaher [mailto:[EMAIL PROTECTED]]
Sent: 18. tammik
D]>
To: 'hugh 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
> 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 unsubscrib
8 matches
Mail list logo