On my OSCommerce website I'm using QTPro. Its a clothing store and I have a drop down of different sizes. 1x, 2x, etc. Right now, they're in whatever order. I want them to be in numerical/alphabetical order all the time. It was 'fixed' with the latest update, but it didn't work for me at all. Here's the code that sorts it.
//////////////////////
$q=tep_db_query("select ps. products_stock_id, ps.products_id, ps.products_stock_attributes, ps.products_stock_quantity, pov.products_options_values_id, pov.language_id, pov.products_options_values_name from " . TABLE_PRODUCTS_STOCK . " ps, products_options_values pov where ps.products_id=" . $VARS['product_id'] . " and pov.products_options_values_id = substring_index(ps.products_stock_attributes, '-', -1) order by pov.products_options_values_name desc");
while($rec=tep_db_fetch_array($q)) {
$val_array=explode(",",$rec[products_stock_attributes]);
echo "<tr>";
foreach($val_array as $val) {
if (preg_match("/^(\d+)-(\d+)$/",$val,$m1)) {
echo "<td class=smalltext> ".tep_values_name($m1[2])."</td>";
} else {
echo "<td> </td>";
}
}
for($i=0;$i<sizeof($options)-sizeof($val_array);$i++) {
echo "<td> </td>";
}
echo "<td class=smalltext> $rec[products_stock_quantity]</td><td> </td></tr>";
}
echo "<tr>";
reset($options);
$i=0;
while(list($k,$v)=each($options)) {
echo "<td class=dataTableHeadingRow><select name=option$k>";
foreach($v as $v1) {
echo "<option value=".$v1[1].">".$v1[0];
}
echo "</select></td>";
$i++;
}
} else {
$i=1;
echo "<td class=dataTableHeadingContent>Quantity</td>";
}
echo "<td class=dataTableHeadingRow><input type=text name=quantity size=4 value=\"" . $db_quantity . "\"><input type=hidden name=product_id value=\"" . $VARS['product_id'] . "\"> </td><td width=\"100%\" class=dataTableHeadingRow> <input type=submit name=action value=" . ($flag?"Add":"Update") . "> </td><td width=\"100%\" class=dataTableHeadingRow> </td>";
?>
/////////////////////////////
I can't make heads or tails of it, but is there anything there that would not work the way I want it to?
Thanks.
Edit:
I've narrowed it down to this line, I just need a way to sort this.
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");