David,
I am using
$sql = "SELECT name FROM products ORDER BY clicks DESC LIMIT 10";
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
if ($config_useRewrite)
{
$url = $config_baseHREF."product/".tapestry_hyphenate($row["name"]).".html";
}
else
{
$url = $config_baseHREF."products.php?q=".urlencode($row["name"]);
}
print "<br><a href='".$url."'>".$row["name"]."</a>";
}
}
Thanks
Stephen Elcombe
Online Shopping For
The Big Business Directory
David,
Yes, this code is on index.php. I was thinking that I could display the top ten products as featured products, rather than having them as text links.
Thanks,
Stephen
Hi Stephen,
That's what I wanted to check - because if you just want to replace the featured products with the Top 10 as derived from the query in the above code, then you can simply replace the Featured Products query with the Top 10 query - there's no need to update the featured products database table to do this.
Currently, the Featured Products (just their names) are selected by the SQL genereted by the following code on line 32 of index.php
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
You can simply replace this with:
$sql = "SELECT name FROM products ORDER BY clicks DESC LIMIT 10";
...and that should do the trick!
Cheers,
David.
Hi Stephen,
The queries to update the featured products based on the result of the query above can certainly be inserted into the above code, but I just want to check - what page is the above code running on? Is it within index.php and displayed alongside featured products? Just want to make sure I understand the requirement...
Cheers,
David.