Jump to content

Easy Order Question


tet3828

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.