I’ve made my fixture generating code available via a web page for those who don’t want to delve into programming in order to generate a fixture list.

Fixtures Generator (now in PHP as I didn’t want to have to install Tomcat again). Source code.

I’ve made my fixture generating code available via a web page for those who don’t want to delve into programming in order to generate a fixture list.

Fixtures Generator (now in PHP as I didn’t want to have to install Tomcat again). Source code.

MichaelHello Sir, Need your thoughts on way to plan a 1/4s and 1/2s (quarters & semi ) for teams in 2 pools say A and B each having 8 teams each and the progression to semis and finals ..Pairings and home and away games i will really appreciate . Happy new year

JamesHi I am having trouble with my fixtures as some teams in our league have more than one team so the cant play at home or away at the same time?] can you help. thanks james

SteveHi, Been looking everywhere for one of these that caters for complementary teams as its needed for our cricket club – is there a version of the code including this ‘fix’ available anywhere. Dont know php or java, but I guess I can figure out the logic Steve

bakertPost authorThe existing generator pairs up teams so that they don’t play at home at the same time. If you have (for example) 8 teams the following pairs will never play at home at the same time: 1&5, 2&6, 3&7, 4&8. This works for any number of teams. The pairs are team N and team N + (total number of teams / 2 rounded up).

AdeHi, Is it possible to send the teams from a database rather than from the form? I am doing this but the output is just Array V Array all the way through… Any help is appreciated. Thanks.

bakertPost author@Ade – sounds like the problem is in your code that is fetching the teams from the db rather than with the fixtures code. “Array” is the default string representation of an array in PHP so perhaps you need something like $array[‘team_name’] in your code where you currently have $array?

AdeHi, I have been able to resolve the issue similar to how you’ve suggested. I ran a query and stored the results of that query in a new array passing in the team name each time on each iteration. Thanks!

AdeI am trying to find a way to prevent certain teams playing at home on the same day. I have seen @bakert response at how for 8 teams certain pairings never play at home at the same time, but one of the divisions in my league has 10 teams.. I can’t seem to find a pairing that never occurs…

bakertPost author@Ade the pairings that never play at home at the same time change based on the number of teams. For 10 it’s 1&6, 2&7, 3&8, 4&9, 5&10. It’s always x & x + (n/2) where X is the number of a team and n is the total number of teams.

AdeThanks for that I understand now. That is spot on. Just out of interest, have you come across the best way to store the two teams into two different columns in the database?

AdeCurrently I have the array index numbers storing in the database, but I wish to store the team names instead of the array index numbers. All help is appreciated.

bakertPost authorI’d probably have two tables (assuming MySQL): CREATE TABLE team ( id INT PRIMARY KEY AUTO_INCREMENT UNIQUE NOT NULL, name VARCHAR(255) ) Engine = InnoDB DEFAULT CHARSET=UTF8; CREATE TABLE match ( id INT PRIMARY KEY AUTO_INCREMENT UNIQUE NOT NULL, date DATETIME NOT NULL, home_id INT NOT NULL, away_id INT NOT NULL, home_score INT, away_score INT, FOREIGN KEY (home_team_id) REFERENCES team (id), FOREIGN KEY (away_team_id) REFERENCES team (id) ) Engine = InnoDB DEFAULT CHARSET=UTF8; For each team make a row in the database: INSERT INTO team (name) VALUES (‘Everton’), (‘Liverpool’), (‘Manchester United’), … ; For each fixture make a row in the database: INSERT INTO match (date, home_id, away_id) VALUES (‘2013-04-01 15:00′, 1, 2), (‘2013-04-01 15:00′, 3, 4), …; Then when you want to see the dates and teams in all the fixtures: SELECT m.date, th.name AS team_home, ta.name AS team_away FROM match AS m INNER JOIN team AS th ON m.home_id = th.id INNER JOIN team AS ta ON m.away_id = ta.id; There are lots of other ways to go about it, of course, but this is a reasonable approach IMHO.

AdeThanks for your help, it is very much appreciated. That is something that I already have. I don’t think I explained what I was doing properly! I am trying to get my head around how I can transfer the output of this generator into a database. Currently the array index number is getting inserted into the database, not the team names.. I am already extracting the team names from the database into an array that is being used for the fixtures. The fixtures output on the screen with the team names, but I can’t find a way to insert them into my fixtures table by manipulating the code on here. I seem to get stuck at that point and no matter what I try I can’t seem to manage it. Thanks again.

bakertPost authorI would look into replacing this line:

with something like:

Then at the end of the process you have a data structure you can traverse to generate your SQL. I would also not bother with team names but instead have ids as the input. So get the ids out of the database not the names. Then you can do something like

AdeThanks for the help. I don’t know where this would fit into the code, furthermore I don’t know how to extract the actual team IDs from the loops as they get stored in the array so where we need to pass the values for the sql query I can’t get my head around what to pass into it.. I thought there’d have been somewhere on the internet that had done this before particularly with this code given how popular it is but I have found nothing, it is bizarre..

bakertPost authorTry

`print_r`

on your array – that will show you the structure of it.Anonymousis it possible to have a league with 5 teams to only play 3games

FixturemanAnonymous, you have probably figured it out by now, but anyhow the answer is NO. One cannot have a 5-team league with each team playing 3 matches. To realize this: Imagine the final league table for your league. If all 5 teams play 3 matches the sum of the “Played” column would be 15. But this sum cannot be an odd number. If A and B are two of the teams in your league, then an AvB match would count as one played game in both A’s and B’s number of played matches. The sum of the “Played” column is therefore always an even number.

Paul ClarkI started the season with 19 teams and one dropped out. We are at the half way point of the season (which usually just means a reversal of all first half fixtures) and I would like to revert to an 18 team grid but I am finding it impossible to reconcile the 20 team grid with the 18 team grid. I have 4 venues with two teams which is complicating the situation. It will mean 2 teams with byes each week if I cant solve it, which is less than ideal. Any help would be useful.Cheers

FixturemanPaul, I doubt if this is a solveable problem. As I understand it your goal is to let the 18 remaining teams play the second half of the season in 17 rounds, so that 1) teams sharing stadium are not at home in the same round, and 2) teams are to play each other on opposite venue compared to the first half of the season. (That is: If A played at home versus B in the first half of the season, then B should play at home gainst A in the second half of the season.) It’s condition No 2 that makes this an extremely difficult problem. The only possible way to solve it would be to take an 18-team fixture plan and chose teams in a way that would satisfy condition 2 (without violating condition 1). And frankly, even without condition 1 to consider I doubt if it’s possible. My advice to you is to play the second half of the season with your original fixtures, even if it will result in two teams with bye in each round.

RodHave been running pool leagues for many years. leagues have consisted of 8.10 or 12 teams but need a formula for 14 teams

FixturemanRod, if you click on my username you’ll be taken to an online storage bin with many fixture plans. One of them is called “14 teams”- That should solve your problem. In this 14-team plan teams with the same capital letter (for instance A1 and A2) are never at home in the same round.

bakertPost authorYou can also use the Fixtures Generator linked above http://bluebones.net/fixtures.php which will give you this: http://bluebones.net/fixtures.php?teams=14

JazzydIs VB.net Version available

bakertPost authorNo VB.NET version but I imagine converting the Java or PHP version wouldn’t be very hard. The algorithm is not that complicated.

Geoffplanning a golf tournament 16 players over 9 games each game has 4 players in group so 4 groups of 4 is there away so every player plays with each other at least once in the 9 games

FixturemanGeoff, if you group your players into 8 teams, with 2 players in each team, and then apply the fixture generator for an 8-team league. You can use the first 9 rounds from this fixture generator. This way every player will play with every other player at least once during the 9 games (rounds). However, each player will have one other player with whom he’s always playing, but you said nothing to indicate that this would be a problem.

GeoffIts a little bit of a problem is that the only way possible.

FixturemanGeoff, after round 7 (game 7) all players have played with everybody else once (except the one they are in a team with, whom they’ve played with twice. For the last two rounds (games) you can group them as you like. So they don’t have to play with their fixed partner in rounds 8 and 9, if that helps.

janetI can you advise me how to do a fixture list for 8 team’s but 3 of the team’s have an a and a b teams, every time I try it it’s is giving me results of a and b team are playing at home at the same time rather than one home and one away. man thanks janet

bakertPost authorFor an 8 team event the fixtures list is: http://bluebones.net/fixtures.php?teams=8 The complimentary teams are 1 and 5, 2 and 6, 3 and 7, 4 and 8.

sharonwhat is the rule for having 1 teams with 6 teams playing out of 3 venues home and away. please help. Thanks

bakertPost authorI’m not sure I understand your question Sharon. In a 6-team setup teams 1 and 4, 2 and 5, and 3 and 6 are complementary (that is, they never play at home at the same time as each other). Does that help?

sharoni have 14 teams in league but have 3 venues with 2 teams each how do i do a fixture list .please Thanks Sharon

bakertPost author@Sharon – http://bluebones.net/fixtures.php?teams=14 The complementary teams are 1 and 8, 2 and 9, 3 and 10, 4 and 11, 5 and 12, 6 and 13, and 7 and 14. You can use any of those pairs for the pairs that share venues.

sharonThankyou

Garry FrancisHi I have 4 divisions, Top 3 divisions with 8 teams and I division with 10 teams. Is there a formula that matches them both up as I have venues with Teams in a division of 8 and the division of 10. Can you help

sharonHi again i need your help i have 12 teams with with 8 of those teams playing out of 4 venues. How do i do it. Thanks

FixturemanSharon, if you go to my online storage bin, at the link given at the end of this reply, then you can download my 12 teams fixture plan. In this fixture pan teams with same letter are never at home in the same round. (For instance A1 is never at home when A2 is at home, B1 is never at home when B2 is at home, and so on.) http://www.4shared.com/dir/19186095/a6abdda2/sharing.html#dir=1dHAqz0t

sharonHi Again My pool league has gone pear shaped so need to do another fixture list 12 teams 3 venues have 2 teams each. we only need to play once each thanks sharon

FixturemanSharon, if I understand your problem correctly you can stilll use my fixture plan for 12 teams. Teams A1 and A2 are never at home at the same time. The same is true for B1 and B2, for C1 and C2, and so on.

sharonHi I cant seem to get on to the link 12 teams 3 venues have 2 teams each only need to now play one game each Help please Sharon

FixturemanSharon, if you copy the link and paste it into the site address field (where you now see the bluebones.net address), and then click Enter, you should be taken to the storage bin. I’ve just tried it and it works.

LironThanks for sharing, it look great. However, if I understand correctly this code (I’m not familiar exactly with the programming language) will always generate the same fixture each time. It would be great to have there random options. So if you have game that user can play several seasons- then first season have 1 fixture, and next season will have different one.