uramagget Posted June 15, 2008 Share Posted June 15, 2008 Hi, I'm trying to set-up a tournament, though I want the system to be automated. I'm not sure how to approach this, since I thought the process would be confusing. I want to setup random pairing, but how can that be done and then stored in a row? Plus, I'm not sure how I would display the pairings correctly for [x] round. Can anybody help out this confused user? My basic layout for a bracket is: *removed by request of op* If that is required to help out.. Quote Link to comment https://forums.phpfreaks.com/topic/110315-tournament-bracket-and-pairing/ Share on other sites More sharing options...
DarkWater Posted June 15, 2008 Share Posted June 15, 2008 So you have a database, correct? You need to have a script that randomly pairs people, but only runs after a tournament finishes so you don't screw it up by accident by running it again, and then have a table that keeps track of wins and losses. Quote Link to comment https://forums.phpfreaks.com/topic/110315-tournament-bracket-and-pairing/#findComment-565993 Share on other sites More sharing options...
.josh Posted June 15, 2008 Share Posted June 15, 2008 assuming you have a database and have info in a table: (untested, not on my computer) // select all players, ordering list randomly $sql = "select players from table order by rand()"; $result = mysql_query($sql); // loop to get data from result source while ($r = mysql_fetch_assoc($result)) { $list[] = $r['players']; } // make a 2d array each pos has 2 players in it (last pos will have 1 player if there's // odd number of players $pairs = array_chunk($list, 2); // formatting the results is really up to you... Quote Link to comment https://forums.phpfreaks.com/topic/110315-tournament-bracket-and-pairing/#findComment-566002 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.