Jump to content

recommended way to sort/filter data displayed from a SQL database


lonewolf217

Recommended Posts

I have data that I am pulling from a SQL database and then displaying in a table on my page.  I would like to enhance it so users can sort the columns and have filters on each column to dynamically change what is being viewed.

 

Is this possible in PHP ? Would I be running a new SQL query each time the filter is set?  (this I can do, just seems a bit much) or is there a way to throw all of my data into some array and sort it on the fly ?

 

edit:  just wanted to mention i am not asking someone to write it for me, just let me know what language it is possible in and possibly a point in the right direction.  I am still learning PHP and playing around with things to do on my site which is just a place for experimention right now.  I believe I have heard this is possible when the table is displayed using javascript, but I know even less of java than I do of php so I am trying to avoid that for now

That depends how fast you pick up code, once you understand the javascript used, the php can be kept basic and there you have lovely ajax. The fastest way to do it would be to just reload the page with an ORDER choice;

 

<a href="yourpage.php?order=name&direction=ASC">ORDER BY NAME ASCENDING</a>

 

Then use the obvious variable to build your sql query

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.