Jump to content

how to dynamically code brackets?


karimali831

Recommended Posts

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  8)

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.