lonewolf217 Posted November 21, 2008 Share Posted November 21, 2008 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 Link to comment https://forums.phpfreaks.com/topic/133661-recommended-way-to-sortfilter-data-displayed-from-a-sql-database/ Share on other sites More sharing options...
gevans Posted November 21, 2008 Share Posted November 21, 2008 You could do it with ajax, but you'd still ahve to query the database again. You're always going to use SELECT * FROM table ORDER BY your_row ASC (or DESC depending what they choose) Link to comment https://forums.phpfreaks.com/topic/133661-recommended-way-to-sortfilter-data-displayed-from-a-sql-database/#findComment-695429 Share on other sites More sharing options...
lonewolf217 Posted November 21, 2008 Author Share Posted November 21, 2008 Thanks, yes I know the database queries I would have to use, I am just trying to find the cleanest way to actually run them. I will look into AJAX, is it difficult for a beginner to do something like this ? Link to comment https://forums.phpfreaks.com/topic/133661-recommended-way-to-sortfilter-data-displayed-from-a-sql-database/#findComment-695431 Share on other sites More sharing options...
gevans Posted November 21, 2008 Share Posted November 21, 2008 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 Link to comment https://forums.phpfreaks.com/topic/133661-recommended-way-to-sortfilter-data-displayed-from-a-sql-database/#findComment-695434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.