Query last 20 entries
Posted 08 July 2003 - 05:49 PM
I can\'t display all, but would like to be able to display the last 20 or so pireps in a table.
I AM Able to query the database and display ALL records, but that page will be come waaaaaaaaaay to large very fast ;-)
Thanks for any help or any links you could provide to tutorials that might help me understand how to do this.
Posted 08 July 2003 - 10:13 PM
select count(*) from table;
and stick it in a variable called $max ... and subtract 20 from it.
then make your query string
\"select * from table limit $max,-1\"
which should give you the last 20 lines of the table.
you may want to stipulate an order by clause on a datetime field or unique incremental to make sure the data is the last 20 entries.
Posted 09 July 2003 - 07:15 AM
SELECT * FROM Table ORDER BY Table_id DESC LIMIT 20;
This will display the rows most recent first. May be what you want, and saves an extra query.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users