Random Number Every 24 Hours
Posted 25 August 2006 - 02:31 AM
When ANY user visits my site on for example Monday, they see the number "5" (it is randomly generated out of 100 numbers). Any user who visits my site on Monday will see the number "5".
After 24 hours, the system will randomly choose another number out of 100, for example, 67, and every person who visits my site on Tuesday, will see the number 67.
After another 24 hours, the system will randomly choose another number out of 100, for example, 54, and every person who visits my site on Wednesday will see the number 54.
I hope you guys can help me out.
Posted 25 August 2006 - 02:46 AM
1) Create a cron to run every 24 hours to call a file that does this:
$RandomNumber = rand(1,100); //PICK A NUMBER BETWEEN 1-100
$NumberFile = fopen("numberfile.txt", "w+"); //CREATE A FLATFILE TO STORE THE RANDOM NUMBER
fwrite($NumberFile, "$RandomNumber"); //WRITE THE NUMBER TO THE FILE
fclose($NumberFile); //CLOSE THE FILE
3) Have your script read the flat file "numberfile.txt"
Posted 25 August 2006 - 02:51 AM
If someone can help me come up with a solution to this small problem using only PHP without the use of Cronjobs or database, please let me know. Much appreciated.
Posted 25 August 2006 - 03:06 AM
And as for the cron, if you want to automate this, you really need to use a cron to have it kick off whatever process you end up choosing to create the number. I don't know of any other method that you could automate something like this. i suppose to could create a quasi-daemon in PHP by creating a loop and using sleep()...but this is hooky at best.
Posted 25 August 2006 - 03:17 AM
Posted 25 August 2006 - 03:21 AM
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community
Posted 25 August 2006 - 03:40 AM
Posted 25 August 2006 - 03:47 AM
Posted 25 August 2006 - 11:43 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users