I have a tournament/ladder script and the DB contains a separate table for every tournament. For each round in the tournament there is a "position" and "score" column. So for example, if I was running a three round tournament you would have the following columns in that table:
teamid
name
round1pos
round1score
round2pos
round2score
round3pos
round3score
Now in the admin control panel I have the following code in the "team management" section to allow admins to change these values in the event they need to regress a player or substitute or something of that nature:
$stats2=mysql_query("SELECT * FROM tournament_$tournamentid WHERE teamid='$team2[id]'");
$stats2=mysql_fetch_array($stats2);
$tournament=mysql_query("SELECT * FROM tournaments WHERE id='$tournamentid'");
$tournament=mysql_fetch_array($tournament);
$team_stats="
<div id='dashboard'>
<h2 class='ico_mug'>" . LANG_MAN_TOURNAMENT_STATS . "</h2>
<div class='clearfix'>
<table class='ucp_fields' cellpadding='4' cellspacing='3' border='0' align='center' width='640px'>
<tr valign='top'>
<td align='center'>" . LANG_MAN_ROUND . " 1 " . LANG_MAN_POSITION . "</td>
<td class='alt1' align='center'>
<input type='text' name='team[round1pos]' value='$stats2[round1pos]' size='40' maxlength='5' />
</td>
</tr>
<tr valign='top'>
<td align='center'>" . LANG_MAN_ROUND . " 1 " . LANG_MAN_SCORE . "</td>
<td class='alt1' align='center'>
<input type='text' name='team[round1score]' value='$stats2[round1score]' size='40' maxlength='5' />
</td>
</tr>
<tr valign='top'>
<td align='center'>" . LANG_MAN_ROUND . " 2 " . LANG_MAN_POSITION . "</td>
<td class='alt1' align='center'><input type='text' name='team[round2pos]' value='$stats2[round2pos]' size='40' maxlength='5' />
</td>
</tr>
<tr valign='top'>
<td align='center'>" . LANG_MAN_ROUND . " 2 " . LANG_MAN_SCORE . "</td>
<td class='alt1' align='center'>
<input type='text' name='team[round2score]' value='$stats2[round2score]' size='40' maxlength='5' />
</td>
</tr>
</table>
</div>
</div>";
Now obviously I'm calling each position/score manually... But what I would like to do is provide the positions and values for every round within the tournament for that specific team. I would know how to do this if it were rows, but how does it work for columns? Since each tournament can differ in the amount of rounds, I need to make sure it only shows the fields that are available.