You are here:  » Featured random on keywords

Support Forum



Featured random on keywords

Submitted by babrees on Wed, 2010-06-16 08:06 in

Trying to get random featured products based on 3 keywords. Would like all keywords found in products.

I currently have the following in my index.php, but am not sure how to add the keyword bit!...

$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$result);
$merchant = $result[0]["merchant"];
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 15";

TIA
Jill

Submitted by support on Wed, 2010-06-16 12:40

Hi Jill,

Try as follows:

$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$result);
$merchant = $result[0]["merchant"];
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' AND name LIKE '%keyword1%' AND name LIKE '%keyword2%' AND name LIKE '%keyword3%' ORDER BY RAND() LIMIT 15";

Hope this helps!

Cheers,
David.