Sorting a paged column!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
uday8486
Forum Newbie
Posts: 22
Joined: Fri Oct 28, 2011 11:42 pm
Location: Pune, India

Sorting a paged column!

Post 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.
KCAstroTech
Forum Commoner
Posts: 33
Joined: Sat Aug 27, 2011 11:16 pm

Re: Sorting a paged column!

Post 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.
dsnraju
Forum Newbie
Posts: 10
Joined: Sun Oct 30, 2011 3:39 am

Re: Sorting a paged column!

Post 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
Post Reply