I am grabbing information from the DB for a form select list. I want the default for the form to be Orange. The form select options are grabbed from the database that is updated by the user (‘Colors’). So orange is the only color that starts with ‘O’ so I figure there has to be a way to start the sort order with a certain char (in this case O).
Here is what I have that grabs the colors column from the DB and puts the rows into a form option select.
$color_select = mysql_query("SELECT * FROM color");
/* Some stuff here */
echo '<select name="Color" id="color">';
while ($row_item = mysql_fetch_array($color_select)){
$pname = $row_item["color"];
echo "<OPTION value=\"$pname\">$pname</OPTION>";
}
echo '</SELECT>';
/* Some stuff here */
Order by i combination med if är trevligt
Har du därimot flera specialfall är case användbar: