Forum Moderators: coopster
<?
$random_content="../random_content.txt";
$random_content=file("$random_content");
$display=rand(0, sizeof($random_content)-1);
echo $random_content[$display];
?>
So is there anyway to just have that code only run once per day?
I know crons sounds like an easy solution, but my host would not let me run as many crons as I would need.
I think all of this is going to require a lot more work than its really worth. I thought it would be easier.
1. Set up a DB with id, pagename, rotating_text, date
2. Use the php $_SERVER to get the page name that is being accessed.
3. Set the sql SELECT to the page name as the variable.
4. Compare the sql['date'] to getdate() if the date is more than 24*60*60 greater than sql run the script, store the information and display the page. Else, show the information.
It might take a little longer for your page to open when the information needs to be changed, but that would only be once on the first open after the information in the DB has 'expired'. The comparrison should not take too much time.
Justin
Edited: removed #5 redundant.