sorting on cloumn headers acending and desanding
-
hi i would like to know how to sort my dynamic generated table in php when i click on any header row on first click sort acending and on another click sort on decending order. :-D
-
hi i would like to know how to sort my dynamic generated table in php when i click on any header row on first click sort acending and on another click sort on decending order. :-D
If you wanna sort Mysql Data, you should use two difference Mysql Query. For example :
SELECT * FROM table1 ORDER BY filed ASC
SELECT * FROM table1 ORDER BY filed DESCElse if you wanna sort a table in client you should use JavaScript.
-
If you wanna sort Mysql Data, you should use two difference Mysql Query. For example :
SELECT * FROM table1 ORDER BY filed ASC
SELECT * FROM table1 ORDER BY filed DESCElse if you wanna sort a table in client you should use JavaScript.
ya i know these are two commands to show asc and desc but i would like to know that i have a grid table in php and on every field i want to do this and show a image full process to do this this grid is filled by while loop as used in php all dataare there but i want to show sorting on header of the fields click. thanks for reply :-D
-
hi i would like to know how to sort my dynamic generated table in php when i click on any header row on first click sort acending and on another click sort on decending order. :-D
I think you want to load a table and then be able to sort the data by a column after the data is loaded by clicking on the col header, correct? Uh oh, i think i may like jQuery too much as i just posted a different response pointing the user to the jQuery library. Take a look at ajaxrain.com for table plugins to jQuery. I know there's a couple of them out there, if this is what you're looking for
-
hi i would like to know how to sort my dynamic generated table in php when i click on any header row on first click sort acending and on another click sort on decending order. :-D
There would be 3 components to this process- 1. User-facing page with
<div id=data></div>
2. AJAX Javascript 3. Dynamic PHP page The user-facing page will contain an empty div marked by an ID. The AJAX script will be something like- http://whatsaranjit.com/includes/grabData.js[^] Lastly, the PHP page will contain a script like-$sql = "SELECT * FROM table";
if (isset($_GET['q'])) {
$q = $_GET['q'];
$sql .= " ORDER BY $q ASC";
}On your user-facing page, you can make your table header a hyperlink-
<a href='javascript: grabData('headerName', 'data', page.php)'>Sort</a>
When you click the link, it will refresh the SQL query data into the div named 'data' appending the SQL query to order by whatever variable you pass to the AJAX script. You can expand on this to to get it to ascend/descend. Good luck! Ranjit Viswakumar Professional Services Specialist rviswakumar@hostmysite.com http://hostmysite.com/?utm_source=bb[^]