Jump to content

order by


vang163

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/119319-order-by/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/119319-order-by/#findComment-614653
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.