Hi, Im dividing categories from a database into 3 rows, which i have working with the code below. I'm trying to figure out how to get $row['caticn'] into each TD of the table as well. I'm sure it's just a little snippet of code , but i'm unsure how to write it , any help is welcome ...
mysql_select_db($sqldb);
$query = "SELECT DISTINCT prods.cat, cats.caticn
FROM prods
INNER JOIN cats ON (prods.cat = cats.catname)";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {$array[] = $row['cat']; $row['caticn'];}
$chunks = array_chunk($array, ceil(count($array) / 3));
echo '
<table border="0" cellpadding="2">
<tr valign="top">
';
foreach ($chunks as $value)
{
echo '<td><table border="0" cellpadding="5">';
foreach ($value as $cat)
{
$strType = $cat;
$strFileName = str_replace(" ", "_", $strType);
if (!$cat) {$cat = ' ';}
echo '<tr><td><img src="'.$img.'/'.$row["caticn"].'"><br><a href="http://www.mysite.com/'.$strFileName.'.html"><b>'.$strType.'</b></a></td></tr>';
}
echo '</table></td>';
}
echo '
</tr>
</table>
';
maybe im wrong... maybe its very complicated? I dont understand much about arrays, and even less about this foreach stuff......😕