jond Posted November 15, 2009 Share Posted November 15, 2009 Hi, I want to be able to sort a a list of images by clicking a button. I understand how to sort them with an sql query like this. $query = mysql_query("SELECT * FROM images ORDER BY date DESC LIMIT $offset, $rowsPerPage",$con); but how would I have two buttons so that the user could switch between descending and ascending? I've been trying submit buttons with if statements containing the sql query but I'm not having any luck. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/181661-sorting-results-from-sql-query-by-clicking-a-button/ Share on other sites More sharing options...
marklarah Posted November 15, 2009 Share Posted November 15, 2009 $order = (if button one was selected) ? "DESC" : "ASC"; $query = mysql_query("SELECT * FROM images ORDER BY date $order LIMIT $offset, $rowsPerPage",$con); Something like that? I'm not sure... Link to comment https://forums.phpfreaks.com/topic/181661-sorting-results-from-sql-query-by-clicking-a-button/#findComment-958164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.