...

View Full Version : Schedule function help needed



sonny
11-12-2012, 06:37 PM
Hi I am a volunteer youth coach trying to create a function that
will automatically create a team vs team schedule, any odd number
team would get a bye if needed.



$NumberOfGames = 10;//testing
$NumberOfTeams = 12; //testing

function Schedule($NumberOfGames, $NumberOfTeams) {
// I have been trying a while to get this, nothing works correctly
// I don't understand how push can help do this?.
echo $schedule;
}

Schedule($NumberOfGames, $NumberOfTeams);


Thanks
Sonny

Fou-Lu
11-12-2012, 07:07 PM
There isn't anywhere near enough information here. What are the rules for selection of games? I assume that its always one team versus another team, but what rules drive whom plays whom? Does a schedule adjust based on wins and losses?

sonny
11-12-2012, 10:05 PM
There isn't anywhere near enough information here. What are the rules for selection of games? I assume that its always one team versus another team, but what rules drive whom plays whom? Does a schedule adjust based on wins and losses?

Hi, No all teams play against each other the same amount of times over a 10 game
schedule, that's why I am having a hard time with it. I need to use functions I never used
before like pop push etc


what I want to do in theory is really simple, but the coding seems really hard
at least for me.

in the example below for simplicity sake

8 teams play each other over a 10 game schedule that's it, should I have a odd team
they would simply get a bye for that week that's about it.

I would need an array to feed the teams but am not sure what type would be best
because I don't know what built in php functions to use that might accomplish this.
$TeamNames = "team1","team2","team3","team4,"team5","team6,"team7","team8";

the function result should be something like
team1 vs Team9
team5 vs team7
team 2 vs team6
team3 vs team4

Week 1 example and so on for week two

in summery I want to create a simple 10 week schedule ( That's 1 game a week)
where 8 teams play against each other the same amount of times. if I have a odd
number of teams provide a bye if needed.

Thanks
Sonny

sonny
11-13-2012, 07:24 PM
Fou or Anybody? I really need some help with this one
I explained things as clearly as humanly possible.

I need to create a schedule for 8 teams playing each
other for a span of 10 weeks, (that's 10 games each total)

thanks
Sonny

Fou-Lu
11-13-2012, 08:56 PM
So you need a combination based on team count x? That won't equate to 10; if you have 8 teams playing that would equate to. . . 28. Wait is that right?
(8!/(8-2)!)*1/(2!) = 40320/720 * 0.5 = 56 * 0.5 or 28. Yeah, so at 8 teams in order to play ever other team you would require 28 weeks, not 10. To get the 10, you would need exactly 5 teams, so you'd have these combinations:


array (
0 =>
array (
0 => 1,
1 => 5,
),
1 =>
array (
0 => 1,
1 => 4,
),
2 =>
array (
0 => 1,
1 => 3,
),
3 =>
array (
0 => 1,
1 => 2,
),
4 =>
array (
0 => 2,
1 => 5,
),
5 =>
array (
0 => 2,
1 => 4,
),
6 =>
array (
0 => 2,
1 => 3,
),
7 =>
array (
0 => 3,
1 => 5,
),
8 =>
array (
0 => 3,
1 => 4,
),
9 =>
array (
0 => 4,
1 => 5,
),
)


So how do we modify the ruleset to accommodate the 10 weeks instead of the 28? Whom doesn't play whom, and how do we determine that?

sonny
11-13-2012, 09:46 PM
I said in my post above if there is a odd number team just give it a bye?
but I'm not even talking about that since I have 8 teams in my example?
I can't explain things any better or clearer then I have.

its really simple in theory, I don't get what your saying its not that complex
or confusing.

I have 8 teams in the league, each team plays a total of 10 games,
(that's equivalent to a 10 week schedule)

I'm just looking to create a simple basic schedule where they play against each
other that's all there is to it, nothing else to compute or think off.

I have been at this on and off for over 2 months now, that's why I tried to get
help here. when someone explains how to do this I will most likely slap myself in
the head as always,

Sonny

poyzn
11-13-2012, 09:49 PM
function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<=$teams; $i++) {
$output .= '<tr>';
for($j=1; $j<=$teams; $j++) {
$output .= '<td>';
if($i == $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}
print schedule();

sonny
11-13-2012, 09:54 PM
Thanks man, I will try that ASAP, that appears to be exactly what I need to do
guess I will pass the team names to schedule with a array. do you know the best
way to do this within the function?

something like


$teams= 'team1','team2,'team3','team4','team5','team6','team7','team8';


Thanks
Sonny

Fou-Lu
11-13-2012, 09:58 PM
function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<=$teams; $i++) {
$output .= '<tr>';
for($j=1; $j<=$teams; $j++) {
$output .= '<td>';
if($i == $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}
print schedule();


This has repetition in it. I'm under the impression repetition is not desired, so 1 should play 2 only once. That's easy to accommodate though.

Perhaps I'm still not "getting it" here. I still see that if you had 8 teams it would equate to 28 games played, not 10 (9 teams would be 36, 10 would be 45, etc). I'm not sure how you intend to shove the 8 teams into a 10 week period.

sonny
11-13-2012, 10:08 PM
This has repetition in it. I'm under the impression repetition is not desired, so 1 should play 2 only once. That's easy to accommodate though.

Perhaps I'm still not "getting it" here. I still see that if you had 8 teams it would equate to 28 games played, not 10 (9 teams would be 36, 10 would be 45, etc). I'm not sure how you intend to shove the 8 teams into a 10 week period.


Fou, 8 teams are playing a game against each other, every Sunday for 10 weeks
yes eventually they will be playing against each 5 times over 40 games.

every team will play 10 games, there will be 4 games played every Sunday
for a total of 40 games overall.

Sonny

poyzn
11-13-2012, 10:10 PM
This has repetition in it.

It can be easily fixed:


function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<$teams; $i++) {
$output .= '<tr>';
for($j=2; $j<=$teams; $j++) {
$output .= '<td>';
if($i >= $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}

print schedule();

sonny
11-13-2012, 10:48 PM
This function does not give a schedule correctly.



function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<$teams; $i++) {
$output .= '<tr>';
for($j=2; $j<=$teams; $j++) {
$output .= '<td>';
if($i >= $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}

print schedule();

schedule ();

Fou-Lu
11-13-2012, 11:44 PM
Wait step back a step here.
Assuming we have 8 teams in total yes? So we have each team playing 10 games; where do the extra 3 games per team come from (shared over multiple teams of course, so that's. . . 1.5 average I guess)? With only 8 teams in total to play, each team would only require a total of 7 games to play against (hence the 28 total game play for the number of combinations).
Is it just round robin on it? Lets only focus on team 1.


Sunday # | Playing
1 | 2
2 | 3
3 | 4
5 | 6
7 | 8
8 | 2
9 | 3
10 | 4

The part that has me baffled as to how to deal with it is the remaining days beyond the permutation count for the number of teams. So with the above, we cap out on the 7th day, so I don't know how to make up the additional three days.

So the best way I can describe my conundrum here: I can easily calculate and generate the 28 required permutations. But I can't figure out how to match it to a ruleset of 4 per week for 10 weeks (which accounts for 40 games total) which is 12 above the original combination options (or 1.5x per team avg), some teams will need to play multiple other teams (up to 3x) repetition, but I don't know how to select which teams should be doing that.

sonny
11-14-2012, 12:16 AM
Wait step back a step here.
Assuming we have 8 teams in total yes? So we have each team playing 10 games; where do the extra 3 games per team come from (shared over multiple teams of course, so that's. . . 1.5 average I guess)? With only 8 teams in total to play, each team would only require a total of 7 games to play against (hence the 28 total game play for the number of combinations).
Is it just round robin on it? Lets only focus on team 1.

The part that has me baffled as to how to deal with it is the remaining days beyond the permutation count for the number of teams. So with the above, we cap out on the 7th day, so I don't know how to make up the additional three days.

So the best way I can describe my conundrum here: I can easily calculate and generate the 28 required permutations. But I can't figure out how to match it to a ruleset of 4 per week for 10 weeks (which accounts for 40 games total) which is 12 above the original combination options (or 1.5x per team avg), some teams will need to play multiple other teams (up to 3x) repetition, but I don't know how to select which teams should be doing that.

Hi Just trying to create a function where I enter the number of teams, and the number of
games to play, and the function simply creates a schedule, again if I have a odd number of
teams, it gives a team the bye if needed. that's about it.

Sonny

Fou-Lu
11-14-2012, 12:33 AM
Yes, I'm aware of what you want to do. What I'm saying is with 8 teams you cannot play a total of 40 games without partial repetition. So my question is still how to deal with which combinations are chosen for repetition. So I can only write combinations which apply to 7 games per team; that is one team plays every other team once and only once (28 games). If you played 56 total games (repetition allowed), then you could do it evenly with the 8, but not with 40.
The only way to get to the 40 with 8 teams really is to make it so every team only plays a total of 5 games. But again, that creates a problem since you still need to decide which two teams each team will not play against (each team needs to play 7 in order to play completely against each other).

sonny
11-14-2012, 01:03 AM
Yes, I'm aware of what you want to do. What I'm saying is with 8 teams you cannot play a total of 40 games without partial repetition. So my question is still how to deal with which combinations are chosen for repetition. So I can only write combinations which apply to 7 games per team; that is one team plays every other team once and only once (28 games). If you played 56 total games (repetition allowed), then you could do it evenly with the 8, but not with 40.
The only way to get to the 40 with 8 teams really is to make it so every team only plays a total of 5 games. But again, that creates a problem since you still need to decide which two teams each team will not play against (each team needs to play 7 in order to play completely against each other).


as I said teams always play more then once, that's ok, this is not a round robbin or
something its just a basic 10 game (Sunday) schedule that's all, the ideal function would
know how to use byes to get as close as possible to perfect.

when I was coaching 4th and 5th graders we had a lot of teams like 20, now with the 8th
graders next spring, I think the max number of teams would be around 10 or 12. maybe I
will have to limit the amount of teams to work with the function or something, but I would
hate to do that if I don't have too.

I see scheduling like this being done all the time not only based on amount of teams and
weeks to play, but the start times as well, not to mention home and away, Boy when I
first started on this I had no idea how hard it would be.

Sonny

Fou-Lu
11-14-2012, 01:13 AM
What is a byes? I had assumed it was a term you used to simply remove an odd number, but this makes it sound more like a technical term.
Its not a hard problem, its simply a couple of loops. But like I said, you simply don't conform to standard mathematics, so you cannot rely directly on combination calculations. With 8 teams you'll simply end up with either a remainder of 12 or a shortage of 16 games to play. You just can't divide into this number to end up with an even result; there will be overlap but you need to dictate the rules to calculate the overlap.

sonny
11-14-2012, 01:20 AM
What is a byes? I had assumed it was a term you used to simply remove an odd number, but this makes it sound more like a technical term.
Its not a hard problem, its simply a couple of loops. But like I said, you simply don't conform to standard mathematics, so you cannot rely directly on combination calculations. With 8 teams you'll simply end up with either a remainder of 12 or a shortage of 16 games to play. You just can't divide into this number to end up with an even result; there will be overlap but you need to dictate the rules to calculate the overlap.

a bye is if no team has a opponent for the week they do not play that's all
team1 vs bye
tean2 vs team7 ,,,


here is something that is really close to what I need to do this creates a team schedule
and works great for 8 teams, problem is it errors with 10 teams and over and has
no bye. it also does not provide amount of games to play

I found something that creates a scheduleand works great for
8 teams, problem is it errors with 10 and over teams and has
no bye.

phpkode/scripts/item/team-schedule-maker


Sonny

Fou-Lu
11-14-2012, 02:30 PM
Does a game against a 'bye' qualify against the total games played?

sonny
11-14-2012, 03:27 PM
Does a game against a 'bye' qualify against the total games played?


Fou its just a basic 10 week schedule for a youth soccer league
teams play once a week on Sunday 9am, 11am, 1pm and 3pm for
10 weeks that would be based on 8 teams of course. which is low

Yes a bye would count towards a game played since 10 weeks is a season
no matter what, that was a good question, I never thought about that. rain
outs are always made up, and if necessary I always try my best for even teams
one time I had 11 player roster's to get-even teams. that was cutting it close
because you know there's always somebody not showing.

Thanks for thinking about me this mourning.

Sonny

Fou-Lu
11-14-2012, 04:59 PM
See now we're getting somewhere. Does a team vs bye require indication of such? If not, then I'd suggest simply null padding the string up to the required number of games and weeks.
I'll have to write this in java so that I can use a debugger since I'm not at home, and then convert it to PHP.

sonny
11-14-2012, 05:34 PM
See now we're getting somewhere. Does a team vs bye require indication of such? If not, then I'd suggest simply null padding the string up to the required number of games and weeks.
I'll have to write this in java so that I can use a debugger since I'm not at home, and then convert it to PHP.

I think its best to show the word bye when its applied
Team7 vs bye
team4 vs team2 etc

Thanks
Sonny

Fou-Lu
11-14-2012, 05:43 PM
Can bye be randomly assigned? Since the remainder is fractional at 1.5, it means some teams will need to play bye multiple times instead of only once.

sonny
11-14-2012, 06:27 PM
Can bye be randomly assigned? Since the remainder is fractional at 1.5, it means some teams will need to play bye multiple times instead of only once.

Yes as long as its fair as possible to all teams, I will do my best to get even teams
but if one team winds up with one more bye then another I will take care of that manually
same with start times one team might get more of a preferred start time then another
that's just life. personally I like a 9am start time, field is fresh, and ref is into it.

also over a 10 week schedule teams will play each other more then once as well.
as long as the math ups, and match times are spread out as evenly as possible. 99% of
the time I will have even teams, I might even add a week for special
number of teams if I really need too, I have a window of between 9 and 12 players
although 9 has a lot of field to cover, with at least 2 subs per roster.

Sonny

poyzn
11-14-2012, 06:53 PM
:) could you draw a schedule example on a piece of paper and show it to us

Fou-Lu
11-14-2012, 07:04 PM
I can't follow most of what you just said. I haven't a clue how these sports games are played.



also over a 10 week schedule teams will play each other more then once as well.


This re-introduces the exact same problem as before. With 8 teams there is not enough days to cover 2x of every other team, so we have a remainder of 12 games to play when we need 28 and completely excludes these "bye" games.
So we're back to sqrt(1); after every team plays every other team, there remains 12 games left to play. How do we select whom plays for duplicates and factor in these "bye" games? There are not enough games available to play every team twice, so that's not an option unless you bring it up to 56 games in a 10 week period to allot playing every team twice.

You need to figure out the ruleset involved in dealing with remaining days. Standard combinations will not work as there is simply not enough containers to cover the entire set of options.

sonny
11-15-2012, 03:08 AM
I can't follow most of what you just said. I haven't a clue how these sports games are played.



This re-introduces the exact same problem as before. With 8 teams there is not enough days to cover 2x of every other team, so we have a remainder of 12 games to play when we need 28 and completely excludes these "bye" games.
So we're back to sqrt(1); after every team plays every other team, there remains 12 games left to play. How do we select whom plays for duplicates and factor in these "bye" games? There are not enough games available to play every team twice, so that's not an option unless you bring it up to 56 games in a 10 week period to allot playing every team twice.

You need to figure out the ruleset involved in dealing with remaining days. Standard combinations will not work as there is simply not enough containers to cover the entire set of options.


Fou look at it this way if you have 8 teams you'll have 40 games over 10 weeks,
8 /40 = 5 that's 5 games the same teams will wind up playing each other
during the season that happens all the time,

problem I'm having is coding things so they are spread out evenly based on start times
match ups and byes if needed.

if you have 12 teams you'll then have 60 games total, that's normal and so on

Sonny

sonny
11-15-2012, 03:11 AM
:) could you draw a schedule example on a piece of paper and show it to us

This is the ideal data I would need to feed the schedule function



$teams = array('team1','tean2','team3','team4','team5','team6','team7','team8');

$Start_Times = array('9am','11am','1pm','3pm',

$NumberWeeks = 10;/ 10 weeks = that's 40 games based on example


the results returned from the function would look like something like this below

WEEK 1
team1 vs team5 (9am)
team2 vs team6 (11am)
team8 vs team3 (1pm)
team7 vs team4 (3pm)

WEEK 2
team3 vs team7 (9am)
team4 vs team8 (11am)
team5 vs team2 (1 pm)
team6 vs team1 (3pm)

WEEK 3
and so on .....

Sonny

sonny
11-15-2012, 03:19 AM
Guys I'll go even further maybe the function should be given
more data to work with to adopt for different conditions.

1 team names
2 start times
3 number of games to play
4 number of Sundays to play them

I think that's why it may sound confusing
this will let the function calculate things
in a more flexible way because not all seasons will
have the same number of teams.

Sonny

Fou-Lu
11-15-2012, 04:54 PM
Start times at this point is irrelevant. Once you get the array of data you need split up properly, you can schedule time as you need based on ordered array.
You'll need to have a full example. With 12 teams, 60 games is insufficient for every team to play every other team (you need 66 games for that). These are where your rules cannot be calculated mathematically. 8 teams require 28, 9 teams require 36, 10 45, 11 55, 12 66. Coming up with the combinations is the easy part. That's a simple:


function teamPlayCombinations(array $aTeams)
{
$aResult = array();
$iTeams = count($aTeams);
for ($i = 0; $i < $iTeams; ++$i)
{
for ($j = $iTeams - 1; $j > $i; --$j)
{
$aResult[] = array($aTeams[$i], $aTeams[$j]);
}
}
return $aResult;
}

That would give all the possible combinations where order is not important (1 plays 2 is the same as 2 plays 1).
But this is absolutely useless to you if at 8 @ 40 games gives you 12 too many, and 12 @ 60 games gives you 6 short. Scheduling so one team only plays once per week isn't a super easy task, but that just takes some conditional checking to see if they are scheduled to play already.
But like I've been saying, until you specifically resolve your ruleset to dictate how you apply repeated plays (in the case of 8 @ 40) or whom doesn't play (in the case of 12 @ 60), then you cannot properly populate this data.

sonny
11-15-2012, 05:33 PM
Ok, guess I'll pass on this one, I thought I explained it in simple terms, but it sounds like
I don't understand what exactly is required. my take was you simply take 40 games
and evenly spread out the match ups between 8 teams?. that's it.

When you think about it
a bye is nothing more then just like facing another team only you don't play that. I found
some open source league scripts I will install and play with,

I still say the basic schedule function theory should work with number of teams, and
number of games. the hard part is spreading the match ups evenly among all of them.
that's why I sought help here.

I found this script below, problem is it errors when it gets to the part teams play more
then once and also there is no way to enter total games played. but this is something like
how to do it.



class schedule{
var $history=array();
var $num=10;
var $a=array();
function make_teams(){
for($i=1;$i<=$this->num;$i++){
$this->a[]="team ".$i;
}
}

function remove_history($team1,$team2){
if(sizeof($this->history)>0){
foreach($this->history[$team1] as $key => $val){
if($val==$team2&&$val){
$this->history[$team1][$key]=0;
break;
}
}
}
}

function make_history(){
for($i=0;$i<$this->num;$i++){
for($j=0;$j<$this->num;$j++){
if($i==$j) $this->history[$this->a[$i]][]=0;
else $this->history[$this->a[$i]][]=$this->a[$j];
}
}
}

function print_teams(){
print_r($this->teams);
}
function check_temp_history($temphistory,$team){
if(sizeof($temphistory)>0){
foreach($temphistory as $val){
if($val==$team){
return false;
}
}
}
return true;
}
function move(){
$temphistory=array();
for($i=0;$i<$this->num;$i++){
if(sizeof($this->history)>0){
foreach($this->history[$this->a[$i]] as $key => $val){
if($val&&$this->check_temp_history($temphistory,$val)&&$this->check_temp_history($temphistory,$this->a[$i])){
$temphistory[]=$this->a[$i];
$temphistory[]=$val;
break;
}
}
}
}
$this->a=$temphistory;
}

function run(){
for($j=1;$j<$this->num;$j++){
for($i=0;$i<$this->num;$i+=2){
srand();
$r=rand(0,1);
if($r==1){
echo $this->a[$i]."-".$this->a[$i+1];
}
else{
echo $this->a[$i+1]."-".$this->a[$i];
}
echo "<br />";
$this->remove_history($this->a[$i],$this->a[$i+1]);
$this->remove_history($this->a[$i+1],$this->a[$i]);
}
echo "<hr>";
$this->move();
}
}
}

// Do It, make the schedule
$s=new schedule();
//number of teams
$s->num=16;
//makes the teams
$s->make_teams();
//makes the history-all the possibilities of the teams(team1 can play against all and so on)
$s->make_history();

//print schedule
echo '<div align=center><table width=200><tr><td>';
$s->run();
echo '</td></tr></table></div>';

Fou-Lu
11-15-2012, 07:01 PM
Right, which is what the combinations will do for you.
If you run that with 8 teams (which is successful), it will specify 4x teams over 7 weeks, and won't accommodate anything over 7 weeks. Which is expected. If you used 12 (and the script wasn't fubard), it would specify 6 games for 11 weeks.
So scheduling a combination without repeating a team per week is mostly trivial to do. Specifying missing days or overages require a custom ruleset to deal with them. If I specified 3 teams total, then there would be 3 games in total to deal with every combination. That would be 1 game per week for 3 weeks. So what would happen with the other 7 weeks?

sonny
11-16-2012, 02:01 AM
Right, which is what the combinations will do for you.
If you run that with 8 teams (which is successful), it will specify 4x teams over 7 weeks, and won't accommodate anything over 7 weeks. Which is expected. If you used 12 (and the script wasn't fubard), it would specify 6 games for 11 weeks.
So scheduling a combination without repeating a team per week is mostly trivial to do. Specifying missing days or overages require a custom ruleset to deal with them. If I specified 3 teams total, then there would be 3 games in total to deal with every combination. That would be 1 game per week for 3 weeks. So what would happen with the other 7 weeks?


Fou Check this out

Just in case anybody out there is also looking to do something like this, its not done its
probably not even the best way to it, but it works, as I said earlier its not that complex as
it appears, note the teams and start times, it will take whatever number of teams and
start times and do a schedule for you just pass it the number of weeks and it does the
rest.

I'd appropriate, any advice on improving or styling this better



// If you wind up with odd number teams, simply add bye as shown.

$teams = array('Team 1','Team 2','Team 3','Team 4','Team 5','team6','team7','bye');

$season = 'Spring 13';
$league = 'Boys';
$date = '2013-02-03';// Schedule start date
$times = array('9am','11am','1pm','3pm');

$date_bits = explode('-',$date);
$start_day = mktime(0, 0, 0, $date_bits[1], $date_bits[2], $date_bits[0]);

$weeks = 10;

$count = count($teams);
$times = array_slice($times,0,floor($count/2));
$times_count = count($times);
$start = 1;

if($count%2!=0)
{
$teams[] = 'Bye';
$count++;
}

$date_i = 0;
for($i=0;$i<$weeks;$i++)
{
$keyA = $start;
$keyB = $keyA-1; if($keyB<1)$keyB = $count-1;
$tA = array();
$tB = array();
for($k=0;$k<$count-1;$k++)
{
$tA[] = $teams[$keyA];
$tB[] = $teams[$keyB];
$keyA++; if($keyA>$count-1) $keyA = 1;
$keyB--; if($keyB<1) $keyB = $count-1;
}
array_unshift($tA,$teams[0]);
$tB[] = $teams[0];

$inc = 0; // time increment
for($k=0;$k<$count;$k++)
{
if($tA[$k]=='Bye'||$tB[$k]=='Bye') continue;

$col = array();
$col['season'] = $season; //season
$col['league'] = $league; //league
$col['Week'] = 'Week '.($i+1); //Week
$col['date'] = date('Y-m-d',strtotime("+{$i} week",$start_day)); //date
$col['time'] = $times[$inc]; //time
$col['teamA'] = $tA[$k]; //result_teamA
$col['_result'] = 'vs';
//$col['teamA_result'] = '0'; //result_teamA
$col['teamB'] = $tB[$k]; //result_teamB
// $col['teamB_result'] = 0;
$data['results'][] = $col;

$inc++;
if($inc==$times_count) break;
}

$start--; if($start<1) $start = $count-1;

// shift allocated times
$first = $times[0];
$times = array_slice($times,1,count($times));
array_push($times,$first);

}
echo '<div align=center><table width=700 border="1">';
foreach($data['results'] as $result)
{
echo '<tr><td align=center nowrap>'.implode('</td><td align=center nowrap>',array_values($result)).'</td></tr>';
}
echo '</table>';

Fou-Lu
11-16-2012, 04:27 PM
Is that what you want to do with it:


Spring 13 Boys Week 2 2013-02-10 11am Team 1 vs team7
Spring 13 Boys Week 9 2013-03-31 9am Team 1 vs team7

You have a few like that; ultimately this is exactly what my question has been. How do you control whom replays whom when you cannot allot everyone playing every team twice.

It doesn't work properly though. It looks to me that you'll end up with. . . 44 records in there, so that'll be 11 weeks worth, not 10. Since 44 doesn't work with a full combination calculation on sets of 2x, without being able to parse this code entirely (writecodeonline is unhappy about the buffer sizes its using), I can't tell whether it's short or just over.

sonny
11-16-2012, 05:25 PM
Is that what you want to do with it:


Spring 13 Boys Week 2 2013-02-10 11am Team 1 vs team7
Spring 13 Boys Week 9 2013-03-31 9am Team 1 vs team7

You have a few like that; ultimately this is exactly what my question has been. How do you control whom replays whom when you cannot allot everyone playing every team twice.

It doesn't work properly though. It looks to me that you'll end up with. . . 44 records in there, so that'll be 11 weeks worth, not 10. Since 44 doesn't work with a full combination calculation on sets of 2x, without being able to parse this code entirely (writecodeonline is unhappy about the buffer sizes its using), I can't tell whether it's short or just over.

I have always been saying this I'm just looking to create match ups for whatever amount
of teams and start times for 10 weeks. Its as close as you can get, everyone has a match
up for 10 weeks and the times and byes are spread out best as possible. this does exactly
that, problem I am having now is styling the results within the implode, I don't want week
1 on every entry just that group for that week only once, I think the way I did this does
not allow easy format styling.

Sonny



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum