I'm trying to get a table to automatically populate columns based on information in a mysql database. What I need is the first sport to be in column 1, the second in 2, the 3rd in 3, then 4th back in 1 etc... What I get is sport 1 as column 1,2,3 and sport 2 in column 1,2,3 etc... Where has my code gone wrong?
<?php
$q = "SELECT * FROM `Sports` ORDER BY `SportNumber` ASC";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
for($i=0; $i<$num_rows; $i++){
$name = mysql_result($result,$i,"SportTitle");
$a_array = 'Athlete' . mysql_result($result,$i,"SportDatabase");
?>
<tr>
<td width="33%"><label><input type="checkbox" name="$name" <?php if($form->value($name) != "Y" || $athlete[$a_array] != "Y"){ echo" checked"; } ?> /><?php echo($name); ?></label></td>
<td width="33%"><label><input type="checkbox" name="$name" <?php if($form->value($name) != "Y" || $athlete[$a_array] != "Y"){ echo" checked"; } ?> /><?php echo($name); ?></label></td>
<td width="33%"><label><input type="checkbox" name="$name" <?php if($form->value($name) != "Y" || $athlete[$a_array] != "Y"){ echo" checked"; } ?> /><?php echo($name); ?></label></td>
</tr>
<? } ?>
Thanks in advance,
~Scott