hiee
i want to sort a column on the click of hyperlink of header i m doing it by sql query so how so i write javascript for this so that i can call on onclick of hyperlink and column get sorted
hiee
i want to sort a column on the click of hyperlink of header i m doing it by sql query so how so i write javascript for this so that i can call on onclick of hyperlink and column get sorted
When you type in google "js sort list on click" first link you have in results gives you this solution.
You can check it for your issue.
so when you say you have a column, I assume that you are presenting the data in an HTML Table element? I dont see this as a PHP or SQL issue/question.
i think a viable approach is to handle this client side. If you are a familiar with jQuery (a javascript library), there are tons of scripts out there to help you sort data in a table. For example, take a look at this one. I think something like this is what you may be looking for.
otherwise if you are going to try to sort the data server side, you would have to have to initiate a postback, send PHP some value that it knows what columun to sort, then requery SQL to generate a new table based on that column sort. I dont think this would be a good approach.
Again, try to handle this client side.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.