This is what ive got so far to provide the results we have on this page
http://www.thebiggolfstore.com/search/search.php?q=Range+Finder
<?php
if ($numRows = database_querySelect($sql,$rows))
{
print "<table width='100%' border='1' cellpadding='0' cellspacing='0' bordercolor='#CCCCCC'>";
print "<tr>";
foreach($rows as $product)
{
if ($config_useRewrite)
{
$productHREF = "product/".str_replace(" ","-",$product["name"]).".html";
if ($rewrite) $productHREF = "../../".$productHREF;
}
else
{
$productHREF = "products.php?q=".urlencode($product["name"]);
}
print "<td width='25%' valign='top'>";
print "<div align='center'> ";
print "<table width='100%' border='0' cellspacing='0' cellpadding='10'>";
print "<tr>";
print "<td>";
print "<div align='center'> ";
print "<h4><a href='".$productHREF."'>".$product["name"]."</a></h4>";
print "</div>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td>";
print "<div align='center'> ";
print "<div align='center'> ";
if ($product["image_url"])
{
print "<img width='90' src='".$product["image_url"]."' alt='' />";
}
else
{
print " ";
}
print "<br />";
print "<p><h5>".substr($product["description"],0,100)."...</h5></p>";
print "</div>";
print "<p align='center'>";
print "</p>";
print "<h3 align='center'>";
print "<font color='CA0C00' size='2' face='Arial, Helvetica, sans-serif'>";
print "<h4>$".$config_currencyHTML.$product["price"]."</h4>";
print "<h5><a href='".$productHREF."'>Compare Prices</a></h5>";
print "</div>";
print "</td>";
print "</tr>";
print "</table>";
print "</div>";
print "</td>";
}
print "<tr>";
print "</table>";
?>
excluding the
<?php
-
?>
Thanks for the help
Hi,
Here's your code (slightly reformatted) with the counter to start a new row every 4 product. Look for the code referring to $itemCount.
<?php
/* rest of code */
if ($numRows = database_querySelect($sql,$rows))
{
print "<table width='100%' border='1' cellpadding='0' cellspacing='0' bordercolor='#CCCCCC'>";
print "<tr>";
$itemCount = 0;
foreach($rows as $product)
{
if ($config_useRewrite)
{
$productHREF = "product/".str_replace(" ","-",$product["name"]).".html";
if ($rewrite) $productHREF = "../../".$productHREF;
}
else
{
$productHREF = "products.php?q=".urlencode($product["name"]);
}
print "<td width='25%' valign='top'>";
print "<div align='center'> ";
print "<table width='100%' border='0' cellspacing='0' cellpadding='10'>";
print "<tr>";
print "<td>";
print "<div align='center'> ";
print "<h4><a href='".$productHREF."'>".$product["name"]."</a></h4>";
print "</div>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td>";
print "<div align='center'> ";
print "<div align='center'> ";
if ($product["image_url"])
{
print "<img width='90' src='".$product["image_url"]."' alt='' />";
}
else
{
print " ";
}
print "<br />";
print "<p><h5>".substr($product["description"],0,100)."...</h5></p>";
print "</div>";
print "<p align='center'>";
print "</p>";
print "<h3 align='center'>";
print "<font color='CA0C00' size='2' face='Arial, Helvetica, sans-serif'>";
print "<h4>$".$config_currencyHTML.$product["price"]."</h4>";
print "<h5><a href='".$productHREF."'>Compare Prices</a></h5>";
print "</div>";
print "</td>";
print "</tr>";
print "</table>";
print "</div>";
print "</td>";
/* Increment a counter and start a new row if necessary */
$itemCount++;
if ($itemCount == 3)
{
print "</tr>";
print "<tr>";
$itemCount = 0;
}
}
print "<tr>";
print "</table>";
}
/* rest of code */
?>
Hope this helps...