Jump to content


Schedule maker


3 replies to this topic

#1 Hooch

    Young Padawan

  • Members
  • Pip
  • 158 posts
  • Location:Brockville, Ontario

Posted 25 June 2006 - 08:30 PM

I have been asked to design a schedule maker for my local kids soccer league.
But ofcourse this is way above my head. I will try to make it through help from here.
Thank you to everyone who has helped me in the past too :D
Here goes for the schedule maker.
I would need the ability to enter the number of teams, what field to play on, and total times to play each other. << I have this down pat :P
Now comes the hard part.
Randomize the 3 components.

I'm trying to figure out the table set up here.
I would need 3 tables. *please correct me if there's a way to do it with less tables.*
One table for all the teams.
One table for all the fields.
One table to enter the number of games to be played, and also the number of times to play
each team.

Now I have never used the random function in php, but is this the way to go?
Or is there a better way to do this all together? (as in not using php and mysql)

Thank you for your input,
Hooch

#2 BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 26 June 2006 - 08:27 AM

Well, dont make it hard on your self to creating on. I just googled "calendar script" and got this
http://www.calendarscript.com/

#3 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 26 June 2006 - 10:16 AM

Three tables is perfect in my opinion for this. So good on you for that bit.

I wouldn't necessarily go for a random script to make the schedule. I think it would be best to manually enter dates and a field for each game.

However if you still wish to go with random the function is rand();
rand(Low#, High#);

I would suggest the high number to be the number of entries in the table.
The low number would obviously be one.

You can choose a random number for the field, and teams. Time is still best decided by you. Then you can implement some conditions, that each team can't play twice on one weekend ect ect.

My idea on the BEST way to go is, use a calendar script and schedule everything manually. Then give the parents the URL to the calendar.

I hope this helps.

Edited by Lang, 26 June 2006 - 10:17 AM.


#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 June 2006 - 11:54 AM

I agree with lang, but if you want to use the rand() function, you could probably do something like the following to make sure nothing gets selected twice.
for($x=0; $x < $teams; $x++){
	$id = rand($low, $high);
	if(in_array($id, $already_used)){
		$x--;
		continue;
	}

	$sql = mysql_query("UPDATE teams SET whatever = ".$r[$id]." WHERE id = ".$x);
	$already_used[] = $id;
}
In case you can't follow that, the idea is to basically select the time/field/what ever from a table before the loop. Then loop through how ever many teams there are. At the start, select a random id, see if it's been used, if it has, decrement $x and continue (or restart, which ever you want to call it), if it hasn't, update the table with what ever you need to update it will using the id from the previously selected data.

Hope that's not to hard to make sense of, GL.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users