Suchy Posted April 9, 2007 Share Posted April 9, 2007 I want to make a pulldown menu where the user can select how to sort and display info from MySQL. (by date, name...) So far I have this, but it is not working. ... // connect to database connectDB(); if(in("Sort")) { $sort =($_POST['sort']); $query = "SELECT * FROM entries ORDER BY 'sort'"; } else $query = "SELECT * FROM entries ORDER BY 'time'"; $result = mysql_query($query); $entriesResults = getRows($result); ... ... <form id="sort" method="POST" action="<?php $_SERVER['PHP_SELF']?>"> Sort By :<br /> <select name="sort"> <option value="date" selected>Date Submited</option> <option value="name" selected>Name</option> <option value="service">Service</option> <option value="os">OS</option> </select> <input name="Sort" type="submit" id="Sort" value="Sort" /> </form> ... Can someone please tell me where I am going wrong, or maybe point me to some kind of tutorial on this topic. The fields in the database have the names: date, name, service, os Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 $query = "SELECT * FROM entries ORDER BY '$sort'"; need the $ Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Share Posted April 9, 2007 um, i dont know if theres a defualt, but i always specify "sort ASC" or "sort DESC" good luck Quote Link to comment Share on other sites More sharing options...
btherl Posted April 9, 2007 Share Posted April 9, 2007 The default is ASC (ascending) Quote Link to comment Share on other sites More sharing options...
Suchy Posted April 9, 2007 Author Share Posted April 9, 2007 That's it. Thanks Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 happy to help please click solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.