Mysql Order By Problem
Posted: Tue Apr 22, 2003 5:51 pm
I'm trying to get mysql to order a set of values extracted from the database in numerical order for a drop down menu. It does this, but for some reason it only reads the first digit of the number, therefore it places 10 before 9 etc..
Here is the code:
Thanks for your help!
Here is the code:
Code: Select all
$products_options_name = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where patrib.products_id='" . $HTTP_GET_VARSї'products_id'] . "' and patrib.options_id = popt.products_options_id");
echo '<b>' . TEXT_PRODUCT_OPTIONS . '</b><br>';
echo '<table border="0" cellpading="0" cellspacing"0">';
while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {
$selected = 0;
//this is the thing i'm having the problem with:
$products_options = tep_db_query("select products_options_values.products_options_values_id, products_options_values.products_options_values_name, products_attributes.options_values_price, products_attributes.price_prefix from products_attributes, products_options_values where products_attributes.products_id = '" . $HTTP_GET_VARSї'products_id'] . "' and products_attributes.options_id = '" . $products_options_name_valuesї'products_options_id'] . "' and products_attributes.options_values_id = products_options_values.products_options_values_id ORDER BY products_options_values.products_options_values_name ASC");
echo '<tr><td>' . FONT_STYLE_MAIN . $products_options_name_valuesї'products_options_name'] . ': </font></td><td>' . "\n" . '<select name ="idї' . $products_options_name_valuesї'products_options_id'] . ']">' . "\n";
while ($products_options_values = tep_db_fetch_array($products_options)) {
echo "\n" . '<option name="' . $products_options_name_valuesї'products_options_name'] . '" value="' . $products_options_valuesї'products_options_values_id'] . '"';
if ( ($products_options_valuesї'options_values_price'] == 0 && $selected == 0) || ($cart->contentsї$HTTP_GET_VARSї'products_id']]ї'attributes']ї$products_options_name_valuesї'products_options_id']] == $products_options_valuesї'products_options_values_id'])) {
$selected = 1;
echo ' SELECTED';
}
echo '>' . $products_options_valuesї'products_options_values_name'];
if($products_options_valuesї'options_values_price'] != "0.00"){
echo ' (' . $products_options_valuesї'price_prefix'] .'$'. $products_options_valuesї'options_values_price'] .') </option>';
}
};
echo '</select></td></tr>';
}
echo '</table>';