Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Random numbers

  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random numbers

    I have been looking for a script which randomly picks three numbers within a certain range and shows them at a given date & time.

    Until that, the site should show three numbers every five or ten seconds by automatic. All visitors should get the same numbers and should not change even
    when refreshing the site.

    * All visitors see the same numbers
    * New numbers are generated every five or ten seconds and are shown
    * Final and staying numbers are generated at a given time and date

    Could this be done? Any help would be most appreciated.

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yea if I follow you correctly? You want 3 numbers to show for 10 seconds? Then show 3 different ones the next 10 seconds? Then at a specific time you want a predetermine set of 3 numbers shown.

    For instance:

    5:10:15 pm numbers ( 3, 15, 9)
    5:10:20 pm numbers ( 3, 15, 9)

    5:10:25 pm new numbers ( 12, 44, 2)

    Then at 6:00:00 I want to show the numbers ( 5, 20, 25)

    Is this what your talking about?

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that is what im after.

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I don't think there is a way to generate random numbers on the spot for ALL users. You could generate your 3 random numbers with a cron job everyday for all day then put them in a database and call it that way? Would be the same thing just woudn't randomize on the spot.

    PHP Code:
    $time date("H:i:s");
    $my_time "06:00:00";

    if(
    $time == $my_time) {
         
    //winner
    } else {
         
    //query for numbers in db by time frame

    Or I guess you could generate one row in the db with the current numbers and just bump the time against that everytime the the page is loaded. So it will know when to generate new numbers. This would probably be a better way then running a cron job, no need for that. :P
    Last edited by iLLin; 03-25-2007 at 03:42 PM. Reason: Im retarded sometimes and dont think of the best solution the first time :)


  •  

    Posting Permissions

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