You are here:  » Featured Products using columns per row

Support Forum



Featured Products using columns per row

Submitted by cq on Fri, 2008-11-07 17:59 in

Hello David,

How can i create featured products using 2/3columns per row something like atoz for the following script.

<?php
  $sql 
"SELECT * FROM `".$config_databaseTablePrefix."products` WHERE merchant = 'abc' ORDER BY RAND() LIMIT 9";
  
database_querySelect($sql,$products);
  foreach(
$products as $product)
  {
  if (
$product["image_url"])
  {
    
$productHREF $config_baseHREF."product/".str_replace(" ","-",$product["name"]).".html";
 print 
"<td>";
 print 
"<br />";
 print 
"<small><a href='".$productHREF."' ><img width='120' height='120' border=0 src='".$product["image_url"]."' alt='".$product["name"] ."' /></a></small><br />";
 print 
"<br />";
 print 
"<font size=2> <a href='".$productHREF."'> ".$product["name"]."</a><br />";
 print 
"<br />";
 print 
$config_currencyHTML.$product["price"]." <br /></font>\n";
 print 
"<br />";
?>

<?php
 
print "</td>";
  }
  else
  {
    print 
"<td>&nbsp;</td>";
  }
}
 print 
"</tr>";
 print 
"</table>";
?>

thanks
jack

Submitted by support on Sat, 2008-11-08 17:54

Hello Jack,

There's code for modifying the featured product HTML into rows in this thread:

http://www.pricetapestry.com/node/284

In your code, you should be able to do the same thing, replacing:

 print "</tr>";

...with:

  if ($count++ == 3)
  {
    print "</tr><tr>";
    $count = 0;
  }

Cheers,
David.