Re: Fetching (and displaying) the 3 newest items from MySQL

From: Date: Fri, 15 Dec 2000 20:53:32 +0000
Subject: Re: Fetching (and displaying) the 3 newest items from MySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-5278@lists.php.net to get a copy of this message
Assuming you are using id as the name of the ID column, use the SQL Query: select * from table order by id desc limit 3 Then loop through the three results, using whichever method you want (the result of the query will return the last three results, from newest to oldest. Matthew At 09:34 PM 12/15/2000 +0100, you wrote:
Hi, I'm a newbie in need of your great wisdom. I need help on how to fetch the three most newly added items from a specific table in a MySQL database. The records in the table are NOT dated, but they do contain have an ID, that is highest for the most newly added item. So, what I want to do is: 1. Take the table and order it with the highest ID first 2. And then take the first 3 items. 3. After that, I also need to display the 3 items, of course! Can you please help me? I'm very new to PHP, but so far I'm very impressed by it! /Mattias


« previous php.db (#5278) next »