PDA

View Full Version : Random Game Generator



MommaCassie
01-23-2006, 06:58 PM
If I have a series of dhtml and javascript games, is there any way to place code that will randomly provide a different game every 24 hours? I have a number of games on my site, but I would like to feature a different one each day on my home page and I would like it to automatically switch during the wee hourse of the morning. I didn't see anything on Dynamic Drive that I thought would do that. Please let me know if I missed it or where I might find it elsewhere (or what to call it for a search - "random game generator" didn't do it for me).

Twey
01-23-2006, 07:19 PM
Doing this server-side would be easiest.

MommaCassie
01-23-2006, 11:34 PM
Thank you. :)

Do you know of a good place for me to read up on how to do that? I have only a little experience working server side and have no clue how to make that happen.:o

Twey
01-24-2006, 07:38 PM
Depends on what language(s) you have installed and enabled on your webserver.
In PHP, if you have the code for one game in game1.inc.html, and the code for the second in game2.inc.html, and so on, you could use:
$numGames = 5; // number of games

srand(microtime());
readfile("game2" . floor(rand() % $numGames) . ".inc.html");There's a PHP tutorial here (http://www.w3schools.com/php/default.asp) and an ASP tutorial here (http://www.w3schools.com/asp/default.asp).