tet3828 Posted April 7, 2007 Share Posted April 7, 2007 Can someone direct me to a reference that will show me where in this code do I drop the ORDER by command to alphabetize my drop down box? $fields = mysql_list_fields("21support", "apps", $connection); $columns = mysql_num_fields($fields); echo "<form action=page_to_post_to.php method=POST><select name=Field>"; for ($i = 0; $i < $columns; $i++) { echo "<option value=$i>"; echo mysql_field_name($fields, $i); } echo "</select></form>"; ?> Link to comment https://forums.phpfreaks.com/topic/46034-easy-order-question/ Share on other sites More sharing options...
redking Posted April 7, 2007 Share Posted April 7, 2007 I'm guessing you have an sql query. somthing like $sql = "SELECT * FROM `bar` WHERE `foo` = '1'"; change that to $sql = "SELECT * FROM `bar` WHERE `foo` = '1'" ORDER BY `column` ASC"; ASC goes from 1 to 10 A to Z DESC goes from 10 to 1 Z to A hope this helps Link to comment https://forums.phpfreaks.com/topic/46034-easy-order-question/#findComment-223676 Share on other sites More sharing options...
onlyican Posted April 7, 2007 Share Posted April 7, 2007 It would be best to do something like this $query = "SELECT 21support From Apps ORDER BY FieldName ASC $result = mysql_query($query); instead of using your mysql_list_fields Link to comment https://forums.phpfreaks.com/topic/46034-easy-order-question/#findComment-223678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.