karimali831 Posted June 29, 2012 Share Posted June 29, 2012 Hi, I am looking to expand to support 512 brackets size for a tournament, hard-coding it will simply take forever and mistakes can easily be done.. anyone able to help me to use PHP to dynamically create the brackets? example for front-end and back-end (admin) for 8-team bracket: http://teamx1.com/v3/templates/8.html http://teamx1.com/v3/admin/templates/8.html Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/264974-how-to-dynamically-code-brackets/ Share on other sites More sharing options...
jcanker Posted June 29, 2012 Share Posted June 29, 2012 Off the top of my head, you can build an array. Are there 512 TEAMS or 512 Brackets (1024 teams). probably a more efficient way to store/organize the array, but this is a 1st draft pointing you in the direction I'd go $brackets512 = array(); $brackets512[0 thru 512]=array(); $bracket512[$i][0]==team1 ID $bracket512[$i][1]==team1Score this round $brackets512[$i][2]==team2 ID $brackets512[$i][3]==team2Scorethis round if($brackets512[$i][3] > $brackets512[$i][1] ==team2 moves on, else team1 moves on and gets placed in the appropriate slot in $brackets256 which follows the same array layout If you want everything to be seedings, rather than winner 1/2 plays winner 3/4, then you can store another array, $seedings where index is the seed. Just compare the index of the teams and place them in the appropriate index in $bracketsX Like I said, rough draft with some holes to fill, but that should work Quote Link to comment https://forums.phpfreaks.com/topic/264974-how-to-dynamically-code-brackets/#findComment-1357855 Share on other sites More sharing options...
xyph Posted June 29, 2012 Share Posted June 29, 2012 How are you getting the team information? How are you deciding which team faces which team? Where are you storing the tournament progress? Coding for 512 'brackets' should be as easy as coding for 8, you're just looking at this in the wrong way I can keep helping once you give me the above information. Quote Link to comment https://forums.phpfreaks.com/topic/264974-how-to-dynamically-code-brackets/#findComment-1357948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.