Web Hosting Talk







View Full Version : PHP Daily Bulletin Script, HELP!!


willlangford
11-30-2002, 11:48 PM
Hey,
I am pritty good at PHP/MySQL. I am the school webmaster for www.chehalis.k12.wa.us I am needing the write a daily bulletin sript, but many of the annoucments that we have go for more than one day. So I would like to have one table with all the annoucments ever, and be able to put a range of how long it will run, ie from 11-30-2002 to 12-15-2002. How would I go about selecting that? That is where i am having trouble.

Thanks,

~Will

EXOWorks
12-01-2002, 02:04 AM
For example today is December 1. And you made an announcement on November 20.
And you want it to last for 10 days.

if((time()-$the_date_ann_made)=='864000') {
don't show the annoucement
} else {
show
}

I think this should work..

GanonOfEvil
12-01-2002, 02:10 AM
if you want to specify how long each announcement shall last (like a range) it might be complicated. Basically you will need to find the range of the unix timestamp (thats the only hard part).

GanonOfEvil
12-01-2002, 02:19 AM
86400 = time in seconds for one day. When inserting into the database, you will need to insert the unix time() when the announcement was made and the range (1 day would be 86400). Then when displaying announcements check to see if the new current time is less than when the announcement was made + range.


$announce_made_on = 1038723356; //Unix time when announcement was made

$range = 86400; //one day

$expired_ann_time = $announce_made_on+$range;

if (time()<=$expired_ann_time)
echo $announcement;

EXOWorks
12-01-2002, 06:18 AM
I made it for 10 days... ;) .. It isn't much complicated, its actually simple..

GanonOfEvil
12-01-2002, 04:40 PM
i was tired when i made that post lol