Advanced Search

Results 1 to 4 of 4

Thread: Random Game Generator

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Game Generator

    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).

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Doing this server-side would be easiest.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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:
    Code:
    $numGames = 5; // number of games
    
    srand(microtime());
    readfile("game2" . floor(rand() % $numGames) . ".inc.html");
    There's a PHP tutorial here and an ASP tutorial here.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •