[PHP] getting lines from the highest ID in a database?

2002-04-05 Thread Hawk

Lets say I have a guestbook, and that I only want to show the last entry on
my first page
I cant figure out a good way to do it..
haven't managed to find a mysql command that can do it either, but maybe
there are? :)



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




Re: [PHP] getting lines from the highest ID in a database?

2002-04-05 Thread Michael Virnstein

this should do the trick:

SELECT MAX(field) from table

you have to use MAX to get the highest value in field.

Michael

Jason Wong [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]...
 On Friday 05 April 2002 18:27, Hawk wrote:
  Lets say I have a guestbook, and that I only want to show the last entry
on
  my first page
  I cant figure out a good way to do it..
  haven't managed to find a mysql command that can do it either, but maybe
  there are? :)

 The only reliable way to do it is to have a field in your guestbook table
 which records the time that the entry was made. Then you can:


   SELECT * FROM guestbook ORDER BY time_entered LIMIT 1

 I have set follow-up to [EMAIL PROTECTED] where this belongs.


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 If there is any realistic deterrent to marriage, it's the fact that you
 can't afford divorce.
 -- Jack Nicholson
 */



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




Re: [PHP] getting lines from the highest ID in a database?

2002-04-05 Thread Jason Wong

On Friday 05 April 2002 18:27, Hawk wrote:
 Lets say I have a guestbook, and that I only want to show the last entry on
 my first page
 I cant figure out a good way to do it..
 haven't managed to find a mysql command that can do it either, but maybe
 there are? :)

The only reliable way to do it is to have a field in your guestbook table 
which records the time that the entry was made. Then you can:


  SELECT * FROM guestbook ORDER BY time_entered LIMIT 1

I have set follow-up to [EMAIL PROTECTED] where this belongs.


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
If there is any realistic deterrent to marriage, it's the fact that you
can't afford divorce.
-- Jack Nicholson
*/

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