Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to put this line into this script?


stevennickelby

Recommended Posts

Hello,

 

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price)

as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1'

order by p.products_date_available desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

The above sorts the products by the furthest in the future first

Instead i have been atempting hopelessly to have it sort by

least furthest in the future first (but it has to filter out those where the date has past)

 

So I did this...

 

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price)

as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " pd where to_days(products_date_available) >= to_days(now()) " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1'

order by p.products_date_available asc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

Buy it came back with a syntax error around where the first pink part is

Can someone help?

Link to comment
Share on other sites

Hello,

 

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price)

as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1'

order by p.products_date_available desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

The above sorts the products by the furthest in the future first

Instead i have been atempting hopelessly to have it sort by

least furthest in the future first (but it has to filter out those where the date has past)

 

So I did this...

 

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price)

as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " pd where to_days(products_date_available) >= to_days(now()) " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1'

order by p.products_date_available asc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

Buy it came back with a syntax error around where the first pink part is

Can someone help?

 

I did it!

 

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as 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_date_available desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...