"; $matches = ""; if ($r % ($_POST['weeks'] + 1) == 0) { $week = 1; } else { $week++; } // For each round loop teams / 2 ... it takes 2 to tango... for ($s = 1; $s <= $n / 2; $s++) { // algorithm to take each team "backwards" $hometeam = ($s==1)? 1 : (($r+$s-2) % ($n-1) +2); // algorithm to prevent home and awayteam to be the same $awayteam = ($n - 1 + $r - $s) % ($n -1) +2 ; // let the venue change after each round... homegame... then awaygame.. if ($r %2) { $swap = $hometeam; $hometeam = $awayteam; $awayteam = $swap; } // never print the ghost-team.. if (($hometeam != $ghost) && ($awayteam != $ghost)) { echo "Player ".$hometeam." vs Player ". $awayteam."
"; } } echo "

"; } } echo "

"; echo "
"; echo " Players:"; echo ""; echo ""; echo "
"; echo "
"; ?>