Scroll page back to the top

Sort table columns with PHP and jQuery

Sort table columns with PHP and jQuery

Learn how to apply the sorting functionality to the table columns, where by clicking on the column heading the order of the items changes from ascending to descending and vice versa. We will accomplish this using PHP, Session Variables and some Ajax calls via jQuery.

PHP / MySQL Tutorial

Sebastian Sulinski on 25th Aug 2011

Download Exercise FilesDemo
 
 

01 : Structure (03:53 min)

1  
 

02 : Populate records (04:13 min)

2  
 

03 : Sort on click (04:35 min)

3  
 

04 : Order by (03:44 min)

4  
 
 
 
 

Discussion (7 comments)

  • Lars Inge Holen

    Lars Inge Holen on Tuesday, 30th August 2011

    Great Sebastian, you Rock !!
    What if this table should be printed, what is the easiest way of doing that.

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Tuesday, 30th August 2011

    Hi Lars,
    Thanks for the comment - you've just given me a good idea for the today's tutorial - check the site later today.

    Reply

  • nelson

    nelson on Monday, 13th August 2012

    i have some problem to try on your code, i got error
    "Fatal error: Call to a member function fetchAll() on a non-object in C:\xampp\htdocs\test\sort\index.php on line 22"

    i only change the user name and passowrd to my server user and password.

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Monday, 13th August 2012

    Hi Nelson,
    It looks like you're calling fetchAll() method on a non-object - this is most likely due to the $statement returning empty result. Try to replace:

    $result = $statement->fetchAll(PDO::FETCH_ASSOC);
    

    with:

    $result = null;
    if ($statement) {
    	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
    }
    

    Reply

  • nelson

    nelson on Monday, 13th August 2012

    it's work now.. thanks

    Reply

  • Pari Ojha

    Pari Ojha on Friday, 16th August 2013

    Hi Friends, Please help me...i want to sorting dynamic html table (using php or jquery) but unable to do. so please help me.

    Thanks & Regards
    Pari Ojha
    JPRS Infotech

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Friday, 16th August 2013

    Hi Peri,
    Do you have a link to the project somewhere?

    Reply

 
Page 1 of 1
  • First
  • Previous
  • 1
  • Next
  • Last
 
 
Add a comment
Add Comment