Page 1 of 1

Sorting a paged column!

Posted: Sat Oct 29, 2011 12:03 am
by uday8486
I have a requirement where i need to sort the column of information suppose name. of only the records displayed on the page.

I mean if there are 100 records totally and only 10 records are displayed per page and when i click on sort button (or a link , or whatever) then only the recors on the page i.e. 10 records must get sorted and not the whole 100 records.

Re: Sorting a paged column!

Posted: Sat Oct 29, 2011 3:32 am
by KCAstroTech
So you want to sort only those 10 on the page not the whole list? Ok... This can be done via php but I suggest looking into jQuery and one of the many sort plugins available such as http://tablesorter.com/docs/. In this way the php supplies the 10 that are being displayed then javascript will sort them by whichever column you want without reloading the page.

Re: Sorting a paged column!

Posted: Sun Oct 30, 2011 4:25 am
by dsnraju
You should use SQl query for displaying 10 records per page

give prev and next as link and display 10 records per page

The Example sql query is here

Examples:

SELECT * FROM `your_table` LIMIT 0, 10

This will display the first 10 results from the database.

SELECT * FROM `your_table` LIMIT 5, 5

This will show records 6, 7, 8, 9, and 10