summerpewp Posted February 9, 2008 Share Posted February 9, 2008 I'm trying to design a tournament bracket similar to http://www.tourneylogic.com/ Except using php / mysql This is a lot I'm trying to take on and i am some what new to php. How should I go about adding the new field.. I will have a button established that when clicked "New opponent" a new entry will be entered similar to the link mentioned above. I have the form of the tournament style under wraps. just need to know how to go about adding it. here is what i have. 2 players <div class="bracket1">NAME 1</div> <div class="empty"> </div><div class="bracketw"> Winner </div> <div class="bracket2">NAME 2</div> 3 Players <body> <div class="bracketbody1"> <div class="bracket1"> Name 1 </div> <div class="empty"> </div> <div class="bracket2"> Name 2</div> </div> <div class="bracketbody"> <div class="empty2"> </div> <div class="bracket1">Winner 1</div> <div class="empty3"> </div> <div class="empty"> </div><div class="bracketw"> Winner </div> <div class="empty3"> </div> <div class="bracket2">Name 3</div> </div> 4 Players <div class="bracketbody1"> <div class="bracket1"> Name 1 </div> <div class="empty"> </div> <div class="bracket2"> Name 2</div> <div class="empty2"> </div> <div class="bracket1"> Name 3 </div> <div class="empty"> </div> <div class="bracket2"> Name 4</div> </div> <div class="bracketbody"> <div class="empty2"> </div> <div class="bracket1">Winner 1</div> <div class="empty3"> </div> <div class="empty"> </div><div class="bracketw"> Final Winner </div> <div class="empty3"> </div> <div class="bracket2">Winner 2</div> </div> 5 Players <body> <div class="bracketbody1"> <div class="bracket1"> Name 1 </div> <div class="empty"> </div> <div class="bracket2"> Name 2</div> </div> <div class="bracketbody1"> <div class="empty2"> </div> <div class="bracket1"> Winner 1</div> <div class="empty"> </div> <div class="empty"> </div> <div class="empty"> </div> <div class="bracket2"> Name 3</div> <div class="empty2"> </div> <div class="empty2"> </div> <div class="bracket1"> Name 4</div> <div class="empty"> </div> <div class="empty"> </div> <div class="empty"> </div> <div class="bracket2"> Name 5</div> </div> <div class="bracketbody"> <div class="empty2"> </div> <div class="empty2"> </div> <div class="empty2"> </div> <div class="bracket1">Winner 2</div> <div class="empty3"> </div> <div class="empty3"> </div> <div class="empty"> </div><div class="bracketw"> Final Winner </div> <div class="empty3"> </div> <div class="empty"> </div> <div class="empty"> </div> <div class="bracket2">Winner 3</div> </div> etc.. etc... The extra php features will be added such as "who is actually Team 1, Team 2, etc... thats not hard.. the hard part is getting the correct size / layout / etc for the fields Example, If there are 30 people, how do you recognize how many fields to imput and where? Link to comment https://forums.phpfreaks.com/topic/90271-php-tournament-bracket-system/ Share on other sites More sharing options...
summerpewp Posted February 10, 2008 Author Share Posted February 10, 2008 does anyone know how to go about this? Link to comment https://forums.phpfreaks.com/topic/90271-php-tournament-bracket-system/#findComment-462978 Share on other sites More sharing options...
markal3x Posted April 24, 2008 Share Posted April 24, 2008 I'm also looking to develop something similar for jiu-jitsu tournaments and I am helping to organize. Creating the brackets is a division question. You get the total number of competitors in a division and divide by two to create the first round match ups. If there is a remainder, a by is given. use php floor function to round down the fraction in the likely hood that there is one and then subtract that number from the previous total value to determine the existence of a remainder or by. <?php $totalComptetitors = 31; $firstRoundBrkt = floor($totalCompetitors/2); $firstRoundBy = $totalCompetitors - $fristRoundBrkt ?> So... 15 first round matches and 1 by. <?php $secondRoundCompetitors = $firstRoundBrkt + $firstRoundBy; $secondRoundBrkt = floor($secondRoundCompetitors / 2); $secondRoundBy = $secondRoundCompetitors - secondRoundBrkt; ?> For the second round we add the total number of winners from the first 15 matches (presumably 15) and add the by (if there is one) creating a total number of 16 2nd round competitors. divide that by two again to get your 2nd round brackets. Determine if there is a by (this time there is not, you have an even 16 matches). So, the next trick is to turn the above into a function that loops until the total number of competitors in a round is equal to 2 (the final match). I'll write more later if no one else picks up the ball in the meantime. I have to get back to work. After bracket creation is completed need to address the following: seeding competitors, identifying match winners, loosing brackets or at least 3rd and 4th place match ups. Link to comment https://forums.phpfreaks.com/topic/90271-php-tournament-bracket-system/#findComment-526380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.