I have a database full of categories, and I would like to show each one in an html table cell. I can't seem to figure out how to actually divide the results into cells.
EX:
<table width="741" border="0" cellpadding="3">
<tr>
<td width="239" height="100" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
<td width="237" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
<td width="239" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
</tr>
</table>
I would like to show my results in a table like the one above. My problem is that when i use some code like:
$row = mysql_fetch_array($sql);
print_r ($row);
while ($row = mysql_fetch_array($sql))
{
echo'<table width="741" border="0" cellpadding="3">
<tr>
<td width="239" height="100" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
<td width="237" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
<td width="239" align="center" valign="middle"><img src="ccat/'.$row['picture'].'"/><br />
<a href="#" class="style1">'.$row['description'].'</a>
</tr>
</table>';
}
It shows the same record 3 times in a row, and I can see why, I just don't see how to get around this problem. Does anyone here know how I would show X amount of records, one in a new cell every time, 3 cells to a table? So 9 records would produce 3 tables with 3 cells in each table, showing 9 records total. If I am not being clear enough please ask away. Thanks in advance. 🙂
PS: it doesn't have to be a new table, if you know how to make it so it generates a new row along with individual cell records, that would be cleaner, I just lack the logic behind this one, been trying to solve it for 3 hours or so, and thought it was time to ask for some advice.