Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com > PHP Help - Generating league matches

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 06-13-2013, 05:44 PM PM User | #1 topdown.me New Coder   Join Date: Jul 2011 Posts: 49 Thanks: 4 Thanked 0 Times in 0 Posts Help - Generating league matches Hello. I am building a script that when I run it will generate all my league matches. I have 16 players. I want to do that when I run this script it will generate in a database table all needed information. the table: Player1 | Player2 | Round Example: 1 | 2 | 1 3 | 4 | 1 5 | 6 | 1 .. 1 | 3 | 2 2 | 4 | 2 3 | 5 | 2 .. all availaboe options to make each player fight each other from player 1 to player 16. I was trying to solve it all night and couldnt find a solution. Thanks for help __________________ Need domain? Buy Cheap Domain at Rapid Host :)
 06-14-2013, 12:16 PM PM User | #2 topdown.me New Coder   Join Date: Jul 2011 Posts: 49 Thanks: 4 Thanked 0 Times in 0 Posts Any help? Please. Another explenation: I want to make a script that will generate all possible matches from 1 to 16. More info: I have 16 players in a tournament. I am developing league system and I need a script that will generate all the possible matches by rounds. All possible matches - I mean that Player1 vs player2, player 3 vs player 4, players 1 vs player 3, player 16 vs 15, player 15 vs 5 etc........... My table: Playe1 | Player2| Round In round = 1 it should be all league matches for all players 1-16, in round = 2 the same, just a match that already was in round = 1 can't be in round = 2 In round = 3 the same, just match that already was in round =1, round = 2 can't be in round = 3 .. etc untill all possible combinations are done I am trying to figure it out for a while and couldnt find a solution. Any help will be appreciated! __________________ Need domain? Buy Cheap Domain at Rapid Host :)
06-14-2013, 04:18 PM   PM User | #3
tangoforce
Senior Coder

Join Date: Feb 2011
Posts: 3,979
Thanks: 50
Thanked 489 Times in 477 Posts
What you're asking is essentially help to build an entire site from what I can understand - people are busy with their own projects.

Quote:
 Originally Posted by topdown.me .. etc untill all possible combinations are done
Perhaps listing all the possible combinations would be a good start towards getting help because otherwise it's yet another thing that someone else needs to do for you. If you can list all the possible combinations someone might translate that into code for you. It doesn't help that you're also expecting us to understand how these rounds work without even telling us what sport it is - I know nothing about most sports rounds so that instantly rules me out!

You clearly have an idea but don't seem to be able to work out the steps involved and seem to want someone else to do all the hard work for you. Unfortunately that won't happen here - you need to come up with your logic / site design and then come back with little pieces of the puzzle you need solving. Have a look at the other threads that have lots of replies and you will see that they have a specific problem that they need fixing - those are the threads that get answers
__________________
My helpful sig has gone because a mod below the administrator gave me an infraction - despite the administrator personally agreeing to it.

If you need any php tips or tricks you can PM me.

Last edited by tangoforce; 06-14-2013 at 04:21 PM..

06-14-2013, 09:59 PM   PM User | #4
topdown.me
New Coder

Join Date: Jul 2011
Posts: 49
Thanks: 4
Thanked 0 Times in 0 Posts
Quote:
whot? How did you get to this conclusion? This is just a small piece from my website. I'm running a browser based game with alot of features, and I want to impelement a league system.
What I'm asking you is that I can't figure out the logic of how to create the script and how to loop all the possible combinationsr from 1 to 16..
__________________
Need domain? Buy Cheap Domain at Rapid Host :)

 06-14-2013, 10:24 PM PM User | #5 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,595 Thanks: 4 Thanked 2,597 Times in 2,566 Posts 1 - 16 is a simple matter: PHP Code: ``` \$aAvailable = range(1, 16); // this can be an array from a db\$aPairs = array();\$iAvailable = count(\$aAvailable);for (\$i = 0; \$i < \$iAvailable; ++\$i){    for (\$j = \$i; \$j < \$iAvailable; ++\$j)    {        if (\$i != \$j)        {            \$aPairs[] = array(\$aAvailable[\$i], \$aAvailable[\$j]);        }    }}print_r(\$aPairs);  ``` Which will return a list of. . . 120 pairs of x,y. That should be all combinations covered from 1 - 16 (in this example, you can query a dataset BUT it will need to be a numerical array to work with the loops [since I was too lazy to use a while :P]), without repeating the combinations. So 1, 3 will exist, but 3, 1 will not. If order doesn't matter, and you can have both 1, 3, and 3, 1, simply change the `for (\$j = \$i` to \$j = 0. That would result in, uhh, 240 matches. Edit: oic, doing it in "rounds" is also far more complex. Since you effectively shuffle the numbers around. Should be a relatively easy change overall to gather though, I'll get back. __________________ PHP Code: ``` header('HTTP/1.1 420 Enhance Your Calm');  ``` Last edited by Fou-Lu; 06-14-2013 at 10:28 PM..
 Users who have thanked Fou-Lu for this post: topdown.me (06-15-2013)
 06-14-2013, 10:52 PM PM User | #6 mlseim Master Coder     Join Date: Jun 2003 Location: Cottage Grove, Minnesota Posts: 9,231 Thanks: 8 Thanked 1,054 Times in 1,045 Posts I found these various PHP scripts ... http://speedtech.it/blog/2009/03/15/...algorithm-php/ http://www.************/source/s/rou...ample_full.php http://www.ultramegatech.com/2010/05...ent-scheduler/ Perhaps old scripts, but maybe it might help you out. . Last edited by mlseim; 06-14-2013 at 10:56 PM..
 Users who have thanked mlseim for this post: topdown.me (06-15-2013)
06-14-2013, 10:56 PM   PM User | #7
tangoforce
Senior Coder

Join Date: Feb 2011
Posts: 3,979
Thanks: 50
Thanked 489 Times in 477 Posts
Quote:
 Originally Posted by topdown.me This is just a small piece from my website. What I'm asking you is that I can't figure out the logic of how to create the script and how to loop all the possible combinationsr from 1 to 16..
And now you've mentioned that, you get two more people reply

See what I was getting at?
__________________
My helpful sig has gone because a mod below the administrator gave me an infraction - despite the administrator personally agreeing to it.

If you need any php tips or tricks you can PM me.

 06-15-2013, 05:27 PM PM User | #8 topdown.me New Coder   Join Date: Jul 2011 Posts: 49 Thanks: 4 Thanked 0 Times in 0 Posts Thank you very much. I found http://www.ultramegatech.com/2010/05...ent-scheduler/ to be very useful. __________________ Need domain? Buy Cheap Domain at Rapid Host :)

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 08:32 AM.