I need to generate sequences of games using the round robin algorithm. I have the php page where the user can input the tournament name which will be inserted into the database and it has got a drop down menu up to 32 teams (select number of teams).
So if I select 4 teams in the page, so it will be from team 1 to team 4 which would be 6 matches because every team plays the other team once. I know how the algorithm works but I am not quite sure how to write the query for that.
I created the table team:
Team_id Teams
01 Team 1
02 Team 2
03 Team 3
etc etc
And a bit of php:
var n = teams; //entered teams
var nr = n-1; //Rounds
$result = mysql_query("SELECT teams from team");
while($row = mysql_fetch_array($result))
{
for(i=1; i<n; i++)
print "{$row} <br>";
}
Can anyone help me to do the rotatation of the arrays to create the round robin, please??