arwo Posted March 19, 2007 Posted March 19, 2007 Hi. :blink: I'd like to sort products page in this way: Firstly column with manufacturers alphabetical Secondly column with theirs (manufacturers) products names alphabetical It should looks like this: PRODUCT LISTING Manufacturer Column + | Products Names Column + -------------------------------|---------------------------------- A.....................................| a (product a of manufacturer A) A.....................................| b (product b of manufacturer A) A.....................................| c (product c of manufacturer A) A.....................................| d (product d of manufacturer A) B.....................................| a (product a of manufacturer B) B.....................................| b (product b of manufacturer B) B.....................................| c (product c of manufacturer B) (don't look at fullstops, i just put them to save width of table to looks clearly) Here is a code with products sorting from "index.php" if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_MANUFACTURER') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by m.manufacturers_name"; break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); $listing_sql .= ' order by '; switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", m.manufacturers_name"; break; case 'PRODUCT_LIST_NAME': $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '') . ", m.manufacturers_name"; break; case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_QUANTITY': $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", m.manufacturers_name"; break; case 'PRODUCT_LIST_IMAGE': $listing_sql .= "pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", m.manufacturers_name"; break; case 'PRODUCT_LIST_PRICE': $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", m.manufacturers_name"; break; } } I tried to do that, but it wasn't working with my ideas... :/ Help me with this problem, please... Thx guys! :thumbsup:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.