Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing SQL query problem


Sketchy

Recommended Posts

The following code is taken from boxes/specials.php.

 

I'm trying to change the SQL query to return a random special offer for a specific category rather than just a random special offer.

 

It's got me stumped - anyine have any suggestions?

 

Thanks.

 

if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

Link to comment
Share on other sites

To the 'where' clause you need to add a condition to only select products from the category you want.

 

something like "and category_id = 20" or whatever.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...