sort button

General discussions related to php

Moderators: egami, macek, gesf

Post Reply

Fri Apr 12, 2013 6:00 am

can I make a sort button in php??
for example, when the user click the button, the name of food will be sorting ascending. In addition, when the user click the button again, the name of food will be sorting descending.

php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Fri Apr 12, 2013 1:25 pm

yes and no. It can be done as you describe if you make use of javascript, either with just javascript, jquery, or ajax. Any of those (they're basically all the same thing implemented differently) will allow you to respond to user input without having to reload the page. to do the same with JUST php and markup, you'd have to make it a form, with a sort_by to order the records on. The button would be submit button (or link if you feel like using GET variables instead of POST) pointing the post of the form back to itself, with the sort variable changed. It can be done so that it refreshes smoothly, but jquery would probably be the quickest and easiest way to get what you want.

Post Reply