Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

need help with mysql order by clause


10seconds

Recommended Posts

Posted

Hi People,

I want to know if you can sort products by one column THEN sort by the nest column.

I have a music / dvd store and want to sort products by Artist then by Title. So for example all the Beatles Cd's are together but the titles are also sorted alphabetically.At present they only sort artists alphabetically ..the titles are all over the place .I worked out how to change the primary sort columns but can 't work out how to add an extra column.

 

here is my code 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_ARTIST') {

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

$listing_sql .= " order by pd.products_artist ";

break;

 

Hope one of the geniuses out there can help me

Cheers

Daniel

Posted
Hi People,

I want to know if you can sort products by one column THEN sort by the nest column.

I have a music / dvd store and want to sort products by Artist then by Title. So for example all the Beatles Cd's are together but the titles are also sorted alphabetically.At present they only sort artists alphabetically ..the titles are all over the place .I worked out how to change the primary sort columns but can 't work out how to add an extra column.

 

here is my code 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_ARTIST') {

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

$listing_sql .= " order by pd.products_artist ";

break;

 

Hope one of the geniuses out there can help me

Cheers

Daniel

 

order by pd.products_artist, pd.products_title

Treasurer MFC

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...