Hi David,
can you tell me please if is possible to adapt the code on this thread http://www.pricetapestry.com/node/2014 to have a "ul" - "/ul" tag closing and opening every 10 rows, similar to this modification: http://www.pricetapestry.com/node/284
Regards,
Andrea
Hi David,
thanks for the new version; only one problem with the loop, I cannot have more than 1 time the tags closing.
Regards, Andrea
Hi Andrea,
Sorry about that - I missed the code to reset $i to zero after each loop - corrected above...
Cheers,
David.
--
PriceTapestry.com
Hi Andrea,
No problem - here's a version of that mod with the
</ul><ul>
every 10 rows, with the number of rows set in a variable at the first line;<?php
$numRows = 10;
print "<h4>Categories</h4>";
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
if (database_querySelect($sql,$rows))
{
$i = 0;
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".$config_baseHREF."search.php?q=brand:".$row["category"]."'>".$row["category"]."</a></li>";
$i++;
if ($i==$numRows)
{
print "</ul><ul>";
$i = 0;
}
}
print "</ul>";
}
print "<h4>Brands</h4>";
$sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";
if (database_querySelect($sql,$rows))
{
$i = 0;
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".$config_baseHREF."search.php?q=brand:".$row["brand"]."'>".$row["brand"]."</a></li>";
$i++;
if ($i==$numRows)
{
print "</ul><ul>";
$i = 0;
}
}
print "</ul>";
}
print "<h4>Merchants</h4>";
$sql = "SELECT DISTINCT(merchant) as merchant FROM `".$config_databaseTablePrefix."products` ORDER BY merchant";
if (database_querySelect($sql,$rows))
{
$i = 0;
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".$config_baseHREF."search.php?q=merchant:".$row["merchant"]."'>".$row["merchant"]."</a></li>";
$i++;
if ($i==$numRows)
{
print "</ul><ul>";
$i = 0;
}
}
print "</ul>";
}
?>
Cheers,
David.
--
PriceTapestry.com