stockychaser Posted March 29, 2011 Share Posted March 29, 2011 I want the result of the code below, so that the dropdown menu is alphabetically ordened.. <label> <select name="StuffCategory" id="StuffCategory" class="validate[required]" style="width: 350px;"> <option value="">Select Stuff Category...</option> <?php while($obj_queryStuffCategory = mysql_fetch_object($result_queryStuffCategory)) { ?> <option value="<?php echo $obj_queryStuffCategory->StuffCatID;?>" <?php if($obj_queryStuffCategory->StuffCatID == $dataAd[stuffCategory]) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryStuffCategory->StuffCategory;?></option> <?php } ?> </select> </label> Link to comment https://forums.phpfreaks.com/topic/232033-how-to-orden-dropdown-menu-alphabetically/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2011 Share Posted March 29, 2011 You would add an ORDER BY column_name term to your query to return the rows in the order that you want them. Link to comment https://forums.phpfreaks.com/topic/232033-how-to-orden-dropdown-menu-alphabetically/#findComment-1193612 Share on other sites More sharing options...
stockychaser Posted March 29, 2011 Author Share Posted March 29, 2011 being a total novice.. where exactly do I put this ? Link to comment https://forums.phpfreaks.com/topic/232033-how-to-orden-dropdown-menu-alphabetically/#findComment-1193807 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2011 Share Posted March 29, 2011 The following is the syntax prototype for a SELECT query. The required position of the ORDER BY term is in red - SELECT [ALL | DISTINCT | DISTINCTROW ] [HIGH_PRIORITY] [sTRAIGHT_JOIN] [sql_SMALL_RESULT] [sql_BIG_RESULT] [sql_BUFFER_RESULT] [sql_CACHE | SQL_NO_CACHE] [sql_CALC_FOUND_ROWS] select_expr [, select_expr ...] [FROM table_references [WHERE where_condition] [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [PROCEDURE procedure_name(argument_list)] [iNTO OUTFILE 'file_name' [CHARACTER SET charset_name] export_options | INTO DUMPFILE 'file_name' | INTO var_name [, var_name]] [FOR UPDATE | LOCK IN SHARE MODE]] Link to comment https://forums.phpfreaks.com/topic/232033-how-to-orden-dropdown-menu-alphabetically/#findComment-1193810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.