vang163 Posted August 12, 2008 Share Posted August 12, 2008 hi, i've a table with 100 records. i displayed the data into 10 records per page, therefore i've 10 pages of data. using this query - "select * from table order by $column $direction limit $set_limit $limit_size" where $column is the table column name $direction - asc or desc Assuming i'm at page 1, I can view the display data (1,2,3,4..10) in ascending order by default. But when i want to display the data in descending order for page 1, I'm getting descending order data from page 10. I want to be able to see the page 1 data in ascending and in descending order. This applies to all other pages. (2,3,4...10) Can someone show me how this can be done, thanks. Quote Link to comment Share on other sites More sharing options...
discomatt Posted August 12, 2008 Share Posted August 12, 2008 When you order by DESC you have to select the last 10 rows, rather than the first 10. I'm not sure if there's a quick way to do this with pure-SQL, but you could simply dump the ASC results into an array, and use array_reverse() if you wanted to display them in reverse order. Quote Link to comment Share on other sites More sharing options...
vang163 Posted August 13, 2008 Author Share Posted August 13, 2008 hi, i have no idea how to dump the ASC results into an array, can you show me how? my initial idea was below but it does not work. $sql = "select * from table"; $result = mysql_query($sql); $asc = mysql_fetch_assoc($result); $reverse_result = array_reverse($asc); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.