The SQL to perform this is quite computationally heavy so may not be suited to being used to display a real time list of the top 30 brands - but in the first instance have a go with the following code inserted into your sidebar:
<?php print "<h4>Top 30 Brands</h4>"; $sql = "SELECT DISTINCT(brand) as brand, COUNT(brand) as count FROM `".$config_databaseTablePrefix."products` GROUP BY brand ORDER BY count DESC LIMIT 30"; if (database_querySelect($sql,$rows)) { print "<ul>"; 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 "<li><a href='".$href."'>".$row["brand"]."</a></li>"; } print "</ul>"; } ?>
Hi atman,
The SQL to perform this is quite computationally heavy so may not be suited to being used to display a real time list of the top 30 brands - but in the first instance have a go with the following code inserted into your sidebar:
<?php
print "<h4>Top 30 Brands</h4>";
$sql = "SELECT DISTINCT(brand) as brand, COUNT(brand) as count FROM `".$config_databaseTablePrefix."products` GROUP BY brand ORDER BY count DESC LIMIT 30";
if (database_querySelect($sql,$rows))
{
print "<ul>";
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 "<li><a href='".$href."'>".$row["brand"]."</a></li>";
}
print "</ul>";
}
?>
Cheers,
David.