tektipsismyfavorite
Technical User
I'm trying a "do" loop to list out a list from a query. I want the list to wrap into the next cell when it gets halfway finished. This is the code I'm using, but for some reason, it's not calculating correctly and it's duplicated the record that is at the halfway point.
Code:
<table cellpadding="1" cellspacing="0" border="0" width="260">
<tr>
<td width="130" align="left" valign="top">
<?php $half = $totalRows_cl*.5; $halfway = round($half); $i=1; ?>
<?php do {
if($i < $halfway){ ?>
<a href="details.php?c=<?php echo $row_cl['clientid']; ?>"><?php echo $row_cl['cname']; ?></a><br />
<?php $i++; } if($i == $halfway){ ?>
<a href="details.php?c=<?php echo $row_cl['clientid']; ?>"><?php echo $row_cl['cname']; ?></a>
</td><td width="130" align="left" valign="top">
<?php $i++; } if($i > $halfway){ ?>
<a href="details.php?c=<?php echo $row_cl['clientid']; ?>"><?php echo $row_cl['cname']; ?></a><br />
<?php $i++; } } while ($row_cl = mysql_fetch_assoc($cl)); ?>
</td>
</tr>
</table>