Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

random select


rkoechel2004

Recommended Posts

Posted

In my installation I have changed "model" to "SKU" and the first 4 digits of the 7 digit SKU tell which department a product is in. My question is i want to use tep_random_select to show random products from a particular department. How do I do a select where products_sku = 1234???

 

Thanks for any help

Ryan

rkoechel2004

Posted
Is the problem that you don't know how to use tep_random_select, or that you don't know how to retrieve the first 4 characters from a string?

 

 

The first 4 characters only from a string, can I just use 3 asterisk after the first 4 digits I want?

rkoechel2004

Posted

No, if you have the SKU in a variable, you can use substr($sku,0,4) in PHP to retrieve the value, or

 

SUBSTRING(sku_column,1,4) in the MySQL query, depending on how you choose to implement it.

 

"sku_column" is obviously the name of the column holding the sku.

Archived

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

×
×
  • Create New...