PDA

View Full Version : now on air



djultra89
11-03-2013, 12:24 AM
hi there could someone help me sort the top bits out
of the coding please as it's not in GMT time or day


<?php //set timezone putenv ('GMT=Europe'); mktime(0,0,0,1,1,1970); $day = date("N"); $time = date("Hi"); if ($day == 7) { switch($time) { case ($time >= '2000' && $time <= '2200'): echo"<img src='http://hyper-radio.co.uk/djimages/djultra.jpg' alt='DJ200 is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1200'): echo"<img src='images/onair/kix103.png' alt='Harold Grimmett is On-Air Now' class='onair'/>"; break; default: echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; break; } } elseif($day == 6) { echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; } else { switch($time) { case ($time >= '0600' && $time <= '0959'): echo"<img src='images/onair/steveandboomer.png' alt='Steve &amp; Boomer is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1459'): echo"<img src='images/onair/kc.png' alt='K.C. Wright is On-Air Now' class='onair'/>"; break; case ($time >= '1500' && $time <= '1859'): echo"<img src='images/onair/jr.png' alt='J.R. Schumann' class='onair'/>"; break; case ($time >= '1900' && $time <= '2359'): echo"<img src='images/onair/jrandalharvey.png' alt='J Randal Harvey is On-Air Now' class='onair'/>"; break; case ($time >= '2400' && $time <= '0559'): echo"<img src='images/onair/blairgarner.png' alt='Blair Garner is On-Air Now' class='onair'/>"; default: echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; break; } } ?>

PapaBearPW
11-04-2013, 08:36 PM
Instead of using putenv(), try using:


date_default_timezone_set("GMT");

That is the proper way to set the default timezone in your script as of php 5.x AFAIK.

Also, I would remove the mktime() function as it is not doing anything...since you don't seem to be setting it to a variable.

djultra89
11-06-2013, 12:22 AM
ok so is this how it goes
please correct me if im wrong


<?php //set timezone putenv date_default_timezone_set("GMT"); mktime(0,0,0,1,1,1970); $day = date("N"); $time = date("Hi"); if ($day == 7) { switch($time) { case ($time >= '2000' && $time <= '2200'): echo"<img src='http://hyper-radio.co.uk/djimages/djultra.jpg' alt='DJ200 is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1200'): echo"<img src='images/onair/kix103.png' alt='Harold Grimmett is On-Air Now' class='onair'/>"; break; default: echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; break; } } elseif($day == 6) { echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; } else { switch($time) { case ($time >= '0600' && $time <= '0959'): echo"<img src='images/onair/steveandboomer.png' alt='Steve &amp; Boomer is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1459'): echo"<img src='images/onair/kc.png' alt='K.C. Wright is On-Air Now' class='onair'/>"; break; case ($time >= '1500' && $time <= '1859'): echo"<img src='images/onair/jr.png' alt='J.R. Schumann' class='onair'/>"; break; case ($time >= '1900' && $time <= '2359'): echo"<img src='images/onair/jrandalharvey.png' alt='J Randal Harvey is On-Air Now' class='onair'/>"; break; case ($time >= '2400' && $time <= '0559'): echo"<img src='images/onair/blairgarner.png' alt='Blair Garner is On-Air Now' class='onair'/>"; default: echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>"; break; } } ?>

PapaBearPW
11-06-2013, 04:43 AM
<?php
//set timezone using date_default_timezone_set()

date_default_timezone_set("GMT");

//mktime(0,0,0,1,1,1970);

$day = date("N");
$time = date("Hi");

if ($day == 7) {
switch($time) {
case ($time >= '2000' && $time <= '2200'):
echo"<img src='http://hyper-radio.co.uk/djimages/djultra.jpg' alt='DJ200 is On-Air Now' class='onair'/>";
break;
case ($time >= '1000' && $time <= '1200'):
echo"<img src='images/onair/kix103.png' alt='Harold Grimmett is On-Air Now' class='onair'/>";
break;
default:
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
break;
}
}
elseif($day == 6) {
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
} else {
switch($time) {
case ($time >= '0600' && $time <= '0959'):
echo"<img src='images/onair/steveandboomer.png' alt='Steve &amp; Boomer is On-Air Now' class='onair'/>";
break;
case ($time >= '1000' && $time <= '1459'):
echo"<img src='images/onair/kc.png' alt='K.C. Wright is On-Air Now' class='onair'/>";
break;
case ($time >= '1500' && $time <= '1859'):
echo"<img src='images/onair/jr.png' alt='J.R. Schumann' class='onair'/>";
break;
case ($time >= '1900' && $time <= '2359'):
echo"<img src='images/onair/jrandalharvey.png' alt='J Randal Harvey is On-Air Now' class='onair'/>";
break;
case ($time >= '2400' && $time <= '0559'):
echo"<img src='images/onair/blairgarner.png' alt='Blair Garner is On-Air Now' class='onair'/>";
break;
default:
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
break;
}
}
?>

djultra89
11-06-2013, 12:51 PM
many thanks great help

PapaBearPW
11-06-2013, 09:07 PM
No problem. Glad to help.

xhilaration
05-26-2017, 08:02 PM
So would this be this est,
nowonair.php? Can I have a stand alone folder - for example:
instead of this: images/djsimg/djpic.jpg
to this: The folder would be 'djsimg'
djsimg/djpic.jpg

Thank you ��

PapaBearPW
06-02-2017, 07:04 AM
If by "est" you mean Eastern Standard Time in the USA for the timezone, then you would need to use:


date_default_timezone_set("US/Eastern");

As to where you put your images, that should work too as long as you address it correctly in the script (see below) and the djsimg folder is located in the same location as the php file.


echo"<img src='djsimg/djpic.jpg' alt='INSERT NAME OF PERSON IN djpic.jpg IMAGE HERE is On-Air Now' class='onair'/>";

Hope that helps.

xhilaration
06-03-2017, 05:18 AM
If by "est" you mean Eastern Standard Time in the USA for the timezone, then you would need to use:


date_default_timezone_set("US/Eastern");

As to where you put your images, that should work too as long as you address it correctly in the script (see below) and the djsimg folder is located in the same location as the php file.


echo"<img src='djsimg/djpic.jpg' alt='INSERT NAME OF PERSON IN djpic.jpg IMAGE HERE is On-Air Now' class='onair'/>";

Hope that helps.

Most definitly, thank you so much!!!

got another ?

can we make this into a file & use a code like this

<echo?=nowplaying.php>
Yes, I don't have the codeing right but this is example.

I want to put a simple php code in the body where I want it to appear vs having to put entire code in body

PapaBearPW
06-03-2017, 06:52 AM
No problem.

Yes. Assuming you name the file "djimg.php", for example, the code to include it in another php script should be:


include "djimg.php";

xhilaration
06-04-2017, 08:53 AM
No problem.

Yes. Assuming you name the file "djimg.php", for example, the code to include it in another php script should be:


include "djimg.php";

ty PapaBear, most apprciative with your help again :)

PapaBearPW
06-04-2017, 09:09 AM
Happy to help when I can.