属性在OSCommerce中的QTPro中排序

时间:2014-05-10 16:44:44

标签: sorting attributes oscommerce

在我的OSCommerce网站上,我使用的是QTPro。它是一家服装店,我有一个不同大小的下拉菜单。 1x,2x等。现在,它们以任何顺序排列。我希望它们始终以数字/字母顺序排列。它被修复了#39;最新的更新,但它根本不适合我。这是对其进行排序的代码。

//////////////////////

$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>&nbsp;&nbsp;&nbsp;".tep_values_name($m1[2])."</td>";
        } else {
          echo "<td>&nbsp;</td>";
        }
      }
      for($i=0;$i<sizeof($options)-sizeof($val_array);$i++) {
        echo "<td>&nbsp;</td>";
      }
      echo "<td class=smalltext>&nbsp;&nbsp;&nbsp;&nbsp;$rec[products_stock_quantity]</td><td>&nbsp;</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'] . "\">&nbsp;</td><td width=\"100%\" class=dataTableHeadingRow>&nbsp;<input type=submit name=action value=" . ($flag?"Add":"Update") . ">&nbsp;</td><td width=\"100%\" class=dataTableHeadingRow>&nbsp;</td>";
?>

/////////////////////////////

我无法做出正面或反面,但那里有什么不符合我想要的方式吗?

感谢。

编辑:

我已将它缩小到这条线,我只需要一种方法对此进行排序。

$ products_attributes_query = tep_db_query(&#34;选择计数(*)作为总和来自&#34; .This_PRODUCTS_OPTIONS。&#34; popt,&#34; .TABLE_PRODUCTS_ATTRIBUTES。&#34; patrib where patrib.products_id = &#39;&#34;。(int)$ HTTP_GET_VARS [&#39; products_id&#39;]。&#34;&#39;&patrib.options_id = popt.products_options_id和popt.language_id =&#39; &#34;。(int)$ languages_id。&#34;&#39;&#34;);

1 个答案:

答案 0 :(得分:0)

这将按名称升序排序。通过将“asc”更改为“desc”来尝试降序。