Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Choosing a random number every day.
Old 07-16-2006, 04:27 PM Choosing a random number every day.
Spin's Avatar
Super Talker

Posts: 113
Trades: 0
How would you choose a number, lets say between 1 and 500, and keep it for 24 hours, then automatically choose another one using PHP (and mysql possibly)?

I plan a "number of the day" feature...
Spin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-16-2006, 06:49 PM Re: Choosing a random number every day.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You could build a script that creates the random number and store in a mySQL db as you mentioned (or even a flat text file).

The easiest way to do this on a 24/hr cycle is to setup a scheduled cron job that executes at midnight everyday. If you don't have cron access, you could have an extra field in your db or flat file that give a timestamp of last modified and check that data for each time the script is manually executed.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-17-2006, 05:27 AM Re: Choosing a random number every day.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
PHP Code:
if (is_file('randnum') && time() - filemtime('randnum') < 3600*24) {
   
// read the number from file
}
else {
   
$number rand(1500);
   
// write the number to the file

__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 07-17-2006, 06:25 AM Re: Choosing a random number every day.
Harvey's Avatar
Super Spam Talker

Posts: 901
Name: Harvey C
Location: Brighton, UK
Trades: 0
Sounds like an exciting feature
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Harvey is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Choosing a random number every day.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16221 seconds with 12 queries