Simple Table sorting in jquery with mysql data

Google+ Pinterest LinkedIn Tumblr

Nowadays, We showed our data in Frid view web content for the client. so for every content we need to use Sorting for Client and also our benefits, But Sorting, searching, pagination is not a easy job in HTML tables with Php and mysql data. So many grid view framework out there, Here we Learn about table sorting in jquery.
DataTable.js is the most popular nowadays. Using jquery and mysql structure we are going to create very simple and easy table sorting functions.

Column sorting is a feature where user can sort the results either in ascending or descending order.

Demo                                                                 Download

Step1 : Setup your database and table in MySQL
Before you run this script make sure you have created a database and table in MySQL. Below is the sample sql command to create a database, table, and insert some dummy rows.

For connect database Check this

Step 2: Fetch records from table and display
Now the next step is simple, fetch all records from MySQL table and display.

Step 3: Include jquery functions for sorting

Step 4 : Add css style for design

construct the table with id ‘table_srot’ and use this id for sorting. thead tag is required for using tablesorter. tbody tag is also required for using tablesorter. using mysql fetching with array you can get the data and using “exact” function you can access exect row asc or dec.
That’s it enjoy the code.

I'm Rajasekar - Web developer, Freelancer, Blogger and Owner of DeveloperDesks. From India lives in Bahrain. I love to do coding, Creating websites and trying different with code and designs. You Can Hire Me