Hey,
I wanted to do a dynamic vertical table with data from MySQL. The table works fine when it’s done horizontally, displaying all the addresses in the address book.
I.E.
[code=html]
<table border=”0″>
<?php do { ?>
<tr>
<td><?php echo $row_dir_us[‘add_1’]; ?></td>
<td><?php echo $row_dir_us[‘add_2’]; ?></td>
<td><?php echo $row_dir_us[‘city’]; ?></td>
<td><?php echo $row_dir_us[‘zip’]; ?></td>
<td><?php echo $row_dir_us[‘state’]; ?></td>
<td><?php echo $row_dir_us[‘country’]; ?></td>
</tr>
<?php } while ($row_dir_us = mysql_fetch_assoc($dir_us)); ?>
</table>
But when I modified it so it would display vertically, with only 3 addresses per row, it only displays the first address ‘x’ times. ‘x’ being the number of addresses in the address book.
I.E.
[code=html]<?php do{
if($cols == 0){
echo “<tr>”;
}?>
<?php if($regs <= $totalRows_dir_us){?>
<td align=”center”>
<table border=”0″>
<tr>
<td align=”center”><?php echo $row_dir_us[‘add_1’]; ?></td>
</tr>
<tr>
<td align=”center”><?php echo $row_dir_us[‘add_2’]; ?></td>
</tr>
<tr>
<td align=”center”><?php echo $row_dir_us[‘city’] . “, “; echo $row_dir_us[‘zip’]; ?></td>
</tr>
<tr>
<td align=”center”><?php echo $row_dir_us[‘state’] . “, “; echo $row_dir_us[‘country’]; ?></td>
</tr>
</table>
</td><?php
$regs++;
$cols++;
} ?>
<?php if($cols == 3 && $regs < $totalRows_dir_us){
$cols = 0;
echo “</tr><tr> </tr>”;
}
if($regs == $totalRows_dir_us){
if($cols < 3){
echo “</tr>”;
}
echo “</table>”;
}?>
<?php } while ($row_dir_us <= mysql_fetch_assoc($dir_us)); ?>
Hope someone can help.
Thanks