Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Displaying all but 1 cpath


iwik

Recommended Posts

Posted

Hi,

 

I've got the all product listing contribution installed, and I'm just trying to work out how to list all but one of my categories.

 

I've tried altering the $listing_sql query in the mail file, changing it from

$listing_sql = "select p.products_id, pd.products_name, pd.products_info, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.authors_name from " . TABLE_PRODUCTS . " p left join " . TABLE_AUTHORS . " m on p.authors_id = m.authors_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' order by pd.products_name";

 

to

 

  $listing_sql = "select p.products_id, pd.products_name, pd.products_info, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, c.categories_id, m.authors_name from " . TABLE_PRODUCTS . " p left join " . TABLE_AUTHORS . " m on p.authors_id = m.authors_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id . "' left join " . TABLE_PRODUCTS_TO_CATEGORIES . " c where p.products_id = c.products_id and p.products_status = '1' and c.categories_id != '42' order by pd.products_name";

 

but I'm getting a "Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/.../public_html/store/all_products.php on line 82" error. (Line 82 is the $listing_sql query)

 

Can anyone see where I've gone wrong with my sql there, or is there another way to prevent displaying a certain category in the all products listing?

 

Any help would be wonderful,

Jane.

Posted
Hi,

 

I've got the all product listing contribution installed, and I'm just trying to work out how to list all but one of my categories.

 

I've tried altering the $listing_sql query in the mail file, changing it from

to

but I'm getting a "Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/.../public_html/store/all_products.php on line 82" error. (Line 82 is the $listing_sql query)

 

Can anyone see where I've gone wrong with my sql there, or is there another way to prevent displaying a certain category in the all products listing?

 

Any help would be wonderful,

Jane.

 

 

get rid of your single quotes

 

'1'

'42'

Treasurer MFC

Posted
get rid of your single quotes

 

'1'

'42'

 

If I get rid of the single quotes around the 1 and 42, I then get the same error, except this time it says the error is on line 95 which is

 

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

 

I'll include the snipped of code which includes the sql statement.

 

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {

    if ( ($column_list[$col] == 'PRODUCT_LIST_BUY_NOW') || ($column_list[$col] == 'PRODUCT_LIST_NAME') || ($column_list[$col] == 'PRODUCT_LIST_PRICE') ) {

      continue;

    }

  }

 

  $listing_sql = "select p.products_id, pd.products_name, pd.products_info, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, c.categories_id, m.authors_name from " . TABLE_PRODUCTS . " p left join " . TABLE_AUTHORS . " m on p.authors_id = m.authors_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id . "' left join " . TABLE_PRODUCTS_TO_CATEGORIES . " c where p.products_id = c.products_id and p.products_status = 1 and c.categories_id != 42 order by pd.products_name";

  include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING_ALL);

?>

        </td>

      </tr>

    </table></td>

<!-- body_text_eof //-->

 

  </tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

Posted
If I get rid of the single quotes around the 1 and 42, I then get the same error, except this time it says the error is on line 95 which is

 

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

 

I'll include the snipped of code which includes the sql statement.

 

 

you are using " and ' together.

 

in my experience you can use this ' " " '

but not this " ' ' "

 

so I would change

 

pd.language_id = '" . $languages_id . "'

 

to

 

pd.language_id = " . $languages_id . "

 

since you encapsulate your entire query with " "

Treasurer MFC

Posted
you are using " and ' together.

 

in my experience you can use this ' " " '

but not this " ' ' "

 

so I would change

 

pd.language_id = '" . $languages_id . "'

 

to

 

pd.language_id = " . $languages_id . "

 

since you encapsulate your entire query with " "

 

Thanks for that Amanda,

 

I went and tinkered with the ' and " marks, comparing it to some other files which had the sql queries in them, and worked out I had a couple of little things wrong - I wasn't joining the TABLE_PRODUCTS_TO_CATEGORIES properly to the rest of it so I was getting errors because of that.

 

So now, the code that is working is:

 

$listing_sql = "select p.products_id, pd.products_name, pd.products_info, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, c.categories_id, m.authors_name from " . TABLE_PRODUCTS . " p left join " . TABLE_AUTHORS . " m on p.authors_id = m.authors_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " c on p.products_id = c.products_id where p.products_status = '1' and c.categories_id != '42' order by pd.products_name";

 

And huzzah! It doesn't show the books in cpath 42 in the all product listing.

 

Thanks for your help!

Archived

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

×
×
  • Create New...