You are here:  » Top product with image

Support Forum



Top product with image

Submitted by rafael95220 on Fri, 2007-07-20 08:49 in

Hello i would like to have a top x product with image, i tested this code

<?php
  $sql 
"SELECT name FROM `".$config_databaseTablePrefix."products` ORDER BY rating DESC LIMIT 10";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      if (
$config_useRewrite)
      {
        
$href $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
      }
      else
      {
        
$href $config_baseHREF."products.php?q=".urlencode($product["name"]);
      }
      print 
"<li><a href='".$href."'>".$product["name"]."</a></li>";
    }
  }
?>

but i can insert the image (replacing text link with image).

thanks and sorry for my english.

Submitted by support on Fri, 2007-07-20 09:01

Hi,

Try something like this (just need to select image_url from the DB and then display it...)

<?php
  $sql 
"SELECT name,image_url FROM `".$config_databaseTablePrefix."products` ORDER BY rating DESC LIMIT 10";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      if (
$config_useRewrite)
      {
        
$href $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
      }
      else
      {
        
$href $config_baseHREF."products.php?q=".urlencode($product["name"]);
      }
      print 
"<p><a href='".$href."'><img src='".$product["image_url"]."' border='0' /></a></p>";
    }
  }
?>

Hope this helps!
Cheers,
David.