Hi everyone, I've managed to create a 'randomizing' fixture list which outputs the following result :
Array ( [0] => Array ( [0] => ARFC vs FRFC [1] => BRFC vs ERFC [2] => CRFC vs DRFC ) [1] => Array ( [0] => ARFC vs BRFC [1] => CRFC vs FRFC [2] => DRFC vs ERFC ) [2] => Array ( [0] => ARFC vs CRFC [1] => DRFC vs BRFC [2] => ERFC vs FRFC ) [3] => Array ( [0] => ARFC vs DRFC [1] => ERFC vs CRFC [2] => FRFC vs BRFC ) [4] => Array ( [0] => ARFC vs ERFC [1] => FRFC vs DRFC [2] => BRFC vs CRFC ) )
Obviously it's an array within an array but I was actually attempting to output it in the format of :
Matchday 1
A v F
B v E
C v D
Matchday 2
...
etc.
My code for my output is:
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="rugby"; // Database name
$connect = mysql_connect(localhost,root,$password)or die("Can't Connect");
mysql_select_db($db_name,$connect)or die("Can't Select Database");
//Make TeamID an array which can be accessed to generate fixtures by randomizing.
$teamid = array('ARFC','BRFC','CRFC','DRFC','ERFC','FRFC');
// this array will be associated with the database.
$fixtures= array();
$TeamIDCount = sizeof($teamid);
$ListofTeamID = array_keys($teamid);
$TemporaryList = array_splice($ListofTeamID,1,sizeof($ListofTeamID)-1);
$count = sizeof($TemporaryList) + 1;
for ($i = 0;$i < $TeamIDCount - 1;$i++)
{
$fixtures[$i] = array();
$fixtures_list = array_merge(array($ListofTeamID[0]), $TemporaryList);
for ($j = 0;$j < $count / 2;$j++)
{
$fixtures[$i][] = $teamid[$fixtures_list[$j]] . ' vs ' . $teamid[$fixtures_list[$count - $j - 1]];
}
// 'Randomises the List
$random = array_shift($TemporaryList);
array_push($TemporaryList, $random);
}
print_r($fixtures);
}
Thanks for reading, and I hope you can help me out.
As my next step would be to allow a user to input scores for each fixture using HTML input commands. This would then update my league table.