Forum Moderators: coopster
while ($subcategory=mysql_fetch_array($subcategory_result)){
echo "<tr>";
for ($i=1; $i<=3; $i++){
echo "<td>html stuff here </td>";
}
echo "</tr>";
}
I tried putting the while within the 'for', but the table row also needs to be looped through so this won't work either.
I really appreciate the patience of the regulars here who help out people like me. I'm actually enjoying doing PHP/MySQL work, but I just don't seem to be very good at it!
And as pathetic as this sounds - I'm actually quite proud of myself for having figured out how to do the counter to create 3 table datas before another table row starts! I just can't get the data into it right now.
$cell = 1;
while ($subcategory=mysql_fetch_array($subcategory_result)){
if ($cell == 1) echo "<tr>";
echo "<td>html stuff here </td>";
if ($cell == 1) {
$cell = 2;
} else if ($cell == 2) {
$cell = 3;
} else {
$cell = 1;
echo "</tr>";
}
}
//at this point we need to make sure the table is closed properly
if ($cell == 2) {
echo "<td> </td></tr>";
} else if ($cell == 3) {
echo "<td> </td>";
echo "<td> </td></tr>";
}
echo "</table>";
I have one lying around somewhere that has a lot tighter code but I figured I would use the verbose one as it is easier to understand the steps.
glad it helped