yandoo Posted March 15, 2009 Share Posted March 15, 2009 Hi I was hoping for a little help with my php code please. I have a drop down list/menu and when an option is selected a mysql query orders the records by the selected option (see pic). A month of a year is stored in a field in each record and i want to be able to add "month" as an option in the drop down. The problem is that i cant work out how to order them by (jan, feb, mar, etc). I can order them a-z but would much rather (jan, feb etc). Im not sure how to do this, if anybody could help that would be great. Thanks mysql_select_db($database_greenfingers, $greenfingers); $query_vege = "SELECT * FROM vegetable ORDER BY $orderby ASC"; $query_limit_vege = sprintf("%s LIMIT %d, %d", $query_vege, $startRow_vege, $maxRows_vege); $vege = mysql_query($query_limit_vege, $greenfingers) or die(mysql_error()); $row_vege = mysql_fetch_assoc($vege); <form name="reorder" method="GET" action="vegetables2.php"> <p><span class="style4">Order By: </span> <select name="orderby" onChange="if(this.value != '-') document.reorder.submit();"> <option "-">Select one...</option> <option value="Name">Name</option> <option value="TypeID">Type</option> <option value="FamilyID">Family</option> </select> </form> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/149549-drop-down-orderby-month/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.