Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Selecting random products that are in stock?


dailce

Recommended Posts

Posted

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 ?????

Posted
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. :)

Posted
The keyword should be AND (upper or lower case) not &&

 

AND and && both work...they're interchangeable. :) i guess it's a matter of preference.

Archived

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

×
×
  • Create New...