Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return the last ten entries, in decending order 1

Status
Not open for further replies.

999Dom999

Technical User
Apr 25, 2002
266
GB
Code:
$row_count = mysql_num_rows(mysql_query("SELECT id FROM en_news"))-10;

$query= "SELECT id,date,title FROM en_news LIMIT $row_count ,10";
Above is the solution of the first part of the question but I want the last entry to display first. I tried:
Code:
$query= "SELECT id,date,title FROM en_news ORDER BY id DESC LIMIT $row_count ,10";
But this counts backwards from the 10th to last entry. I could put the data into an array and display it backwards but I'm sure there is a sql statement to help me do this? Its hurting my little brain. Any ideas?
 
SELECT * FROM (
SELECT id,date,title FROM en_news
ORDER BY id DESC LIMIT $row_count,10 ) AS x
ORDER BY id

if for some reason this doesn't work, sort the 10 rows in php

:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Just the ticket!! Thanks so much!! I was getting a bald patch from head scratching!

I used this and works perfectly:

SELECT * FROM (
SELECT id,date,title FROM en_news
LIMIT $row_count,10 ) AS x
ORDER BY id DESC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top