Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with SQL Sort Order


sek_see

Recommended Posts

I'm changing the normal sort order in my SQL to sort by date added. It works fine until I change pages (as in page 2 of 3), then the other pages reflect a different sort order. I'm not sure where the problem is.

 

The change I made was to the 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_NAME') {

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

$listing_sql .= " order by p.products_date_added desc";

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' : '') . ", pd.products_name";

...

 

 

Would anybody know what other changes I have to make in order to have the sort apply to all split pages?

 

Thank you.

Link to comment
Share on other sites

Go to the product listing page on your site. Click the sort order link above the date added column until the list it is in the order you want. In the URL you will then see a variable called sort.

 

Then change in the code above the following line from:

 

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

 

To:

 

$HTTP_GET_VARS['sort'] = SORT VALUE FROM URL MENTIONED ABOVE;

 

 

Example SORT VALUE - 4d.

Your online success is Paramount.

Link to comment
Share on other sites

THANK YOU, THANK YOU, THANK YOU.

 

All the information provided gave me enough info to figure out what my problem was. Everything works good now. You guys are awesome.

 

Thanks again.

 

 

 

 

Go to the product listing page on your site. Click the sort order link above the date added column until the list it is in the order you want. In the URL you will then see a variable called sort.

 

Then change in the code above the following line from:

 

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

 

To:

 

$HTTP_GET_VARS['sort'] = SORT VALUE FROM URL MENTIONED ABOVE;

Example SORT VALUE - 4d.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...