Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Selecting random products that are in stock?


dailce

Recommended Posts

Hi,

 

My sql skills aren't that great. I have the following from random products. The code selects products that are available.

 

$sql_query[0] = tep_db_query("select p.products_id, p.products_quantity, p.products_image, p.products_tax_class_id, s.status, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_ordered asc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

How can I change this code so that I can select products that are available AND products that have a quantity greater than 0 ?????

Link to comment
Share on other sites

How can I change this code so that I can select products that are available AND products that have a quantity greater than 0 ?????

 

try

 

$sql_query[0] = tep_db_query("select p.products_id, p.products_quantity, p.products_image, p.products_tax_class_id, s.status, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1'  && products_quantity > 0 order by p.products_ordered asc  limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

off the top of my head, i think this should work but i haven't tested it so...standard disclaimers apply. :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...