PDA

View Full Version : EASY PHP HELP NEEDED



wbsweb
11-08-2003, 11:19 PM
Hey you PHP programmer you,

I need to include a PHP script on the bottom of my page that:

if time is 10:00 PM - 8:00 AM, then display banner.htm

if not, then display nothing.


any help?
feel free to ask any questions.

OSFan
11-09-2003, 06:38 AM
Your Webpage



<?PHP include('time.php') ?>


time.php:



<?PHP

//Current hour of day, this is in the server time
$CurHour = date('H');

//If it's greater than or equal to 22 i.e. 10 or 11PM
//Or if it's less than or equal 08 i.e. 00,01,...,08AM
//Include the banner.htm otherwise do nothing
if ($CurHour>=22 || $CurHour<8) {
include('banner.htm');
}

?>


First time the banner is shown is at 22:00 the last is at 07:59.

carbonize
11-09-2003, 01:57 PM
Couldn't he just put the following straight into the page?


<?PHP

//Current hour of day, this is in the server time
$CurHour = date('H');

//If it's greater than or equal to 22 i.e. 10 or 11PM
//Or if it's less than or equal 08 i.e. 00,01,...,08AM
//Include the banner.htm otherwise do nothing
if ($CurHour>=22 || $CurHour<8) {
print 'HTML CODE FOR THE BANNER GOES HERE';
}

?>

remembering of course that he has to change the extension of the page this code is used on to .php so that the server knows to send it to the PHP processor first.

OSFan
11-10-2003, 06:25 AM
Yes.

All depends on how many pages it's being used in. If it's just the one, do it carbonize's way, if it's in many, just include the file into the files.

Yes, don't forget all the pages must be .php that use it ;-).