Hi David,
I want to show 10 random Brands on my header page. I tried a lot with that random products code, but could not manage it. How can I manage that in the coding of header.php?
Thanks and regards
Roland
Hi Roland,
The following code will generate links to 10 random brands:
<?php $sql = "SELECT DISTINCT(brand) FROM `".$config_databaseTablePrefix."products` WHERE brand <> '' ORDER BY RAND() LIMIT 10"; database_querySelect($sql,$rows); print "<p>"; foreach($rows as $row) { if ($config_useRewrite) { $href = $config_baseHREF."brand/".tapestry_hyphenate($row["brand"])."/"; } else { $href = $config_baseHREF."search.php?q=brand:".urlencode($row["brand"]); } print " <a href='".$href."'>".$row["brand"]."</a> "; } print "</p>";?>
Hope this helps!
Cheers, David. -- PriceTapestry.com
Perfect as always. Thanks a lot.
©2006-2025 IAAI Software | Contact Us | Privacy Policy
Hi Roland,
The following code will generate links to 10 random brands:
<?php
$sql = "SELECT DISTINCT(brand) FROM `".$config_databaseTablePrefix."products` WHERE brand <> '' ORDER BY RAND() LIMIT 10";
database_querySelect($sql,$rows);
print "<p>";
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."brand/".tapestry_hyphenate($row["brand"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=brand:".urlencode($row["brand"]);
}
print " <a href='".$href."'>".$row["brand"]."</a> ";
}
print "</p>";
?>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com