Bluehost.com Web Hosting $6.95

Time Display

This is a discussion on Time Display within the alt.comp.lang.php forums, part of the PHP Programming Forums category; This should be a simple one, yet I don't get it. I work for a radio station and I ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-27-2004
Fuzz Martin
 
Posts: n/a
Default Time Display

This should be a simple one, yet I don't get it. I work for a radio
station
and I am trying to use php to post a picture of the personality on the
air,
only while they're on the air. I can get it to work if I don't use the
day
of the week, but I went through and put in a variable for the day of the
week and now it is only showing me sunday's line up.

Help me out and e-mail me your address and I will send you a t-shirt.
(it's
radio, that's all they give me.)

Here's what I've got:

<?
$hour = date('G');
$day = date('w');

if ($day == 0 || $hour < 7) {
?>
<span class="style1 style4">The Better Songs</span><br>
<img src="../images/bettersongs.jpg" width="100" height="100">
<?

} else if ($day == 0 || $hour == 7 || $hour < 11) {
?>
<span class="style1 style4">Crook &amp; Chase<br>8AM-Noon</
span><br>
<a href="crchase.php"><img src="../images/crchase.jpg"
width="100" height="100"></a>
<?

} else if ($day == 0 || $hour == 11 || $hour <= 23) {
?>
<span class="style1 style4">The Better Songs</span><br>
<img src="../images/bettersongs.jpg" width="100" height="100">
<?

} else if ($day == 1 || $hour < 5) {
?>
<span class="style1 style4">The Better Songs</span><br>
<img src="../images/bettersongs.jpg" width="100" height="100">
<?

} else if ($day == 1 || $hour == 5 || $hour < 9) {
?>
<span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
<a href="melliott.php"><img src="../images/melliott.jpg"
width="100" height="100"></a>
<?

} else if ($day == 1 || $hour == 9 || $hour < 14) {
?>
<span class="style1 style 4">Cat Brooks<br>10-3PM</span><br>
<a href="cbrooks.php"><img src="../images/cbrooks.jpg"
width="100" height="100"></a>
<?

} else if ($day == 1 || $hour == 14 || $hour < 18) {
?>
<span class="style1 style 4">Fuzz Martin<br>3-7PM</span><br>
<a href="fmartin.php"><img src="../images/fmartin.jpg"
width="100" height="100"></a>
<?

} else if ($day == 1 || $hour == 18 || $hour < 22) {
?>
<span class="style1 style 4">Lia Knight<br>7-Midnight</span><br>
<a href="lia.php"><img src="../images/lia_head.jpg" width="100"
height="100"></a>
<?

} else if ($day == 1 || $hour == 22 || $hour <= 23) {
?>
<span class="style1 style 4">Danny Wright<br>Midnight-6AM</
span><br>
<a href="dwright.php"><img src="../dwright.php" width="100"
height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour < 5) {
?>
<span class="style1 style4">Danny Wright<br>Midnight-6AM</
span><br>
<a href="dwright.php"><img src="../dwright.php" width="100"
height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour == 5 || $hour < 9) {
?>
<span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
<a href="melliott.php"><img src="../images/melliott.jpg"
width="100" height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour == 9 || $hour < 14) {
?>
<span class="style1 style4">Cat Brooks<br>10-3PM</span><br>
<a href="cbrooks.php"><img src="../images/cbrooks.jpg"
width="100" height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour == 14 || $hour < 18)
{
?>
<span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
<a href="fmartin.php"><img src="../images/fmartin.jpg"
width="100" height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour == 18 || $hour < 22)
{
?>
<span class="style1 style4">Lia Knight<br>7-Midnight</span><br>
<a href="lia.php"><img src="../images/lia_head.jpg" width="100"
height="100"></a>
<?

} else if ($day == 2 || $day <= 5 || $hour == 22 || $hour <=23)
{
?>
<span class="style1 style4">Danny Wright<br>Midnight-6AM</
span><br>
<a href="dwright.php"><img src="../images/danny.gif" width="100"
height="100"></a>
<?

} else if ($day == 6 || $hour < 5) {
?>
<span class="style1 style4">Danny Wright<br>Midnight-6AM</
span><br>
<a href="dwright.php"><img src="../images/danny.gif" width="100"
height="100"></a>
<?

} else if ($day == 6 || $hour == 5 || $hour < 9) {
?>
<span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
<a href="melliott.php"><img src="../images/melliott.jpg"
width="100" height="100"></a>
<?

} else if ($day == 6 || $hour == 9 || $hour < 14) {
?>
<span class="style1 sytle4">Cat Brooks<br>10-3PM</span><br>
<a href="cbrooks.php"><img src="../images/cbrooks.jpg"
width="100" height="100"></a>
<?

} else if ($day == 6 || $hour == 14 || $hour < 18) {
?>
<span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
<a href="fmartin.php"><img src="../images/fmartin.jpg"
width="100" height="100"></a>
<?

} else if ($day == 6 || $hour == 18 || $hour <=23) {
?>
<span class="style1 style4">The Better Songs</span><br>
<img src="../images/bettersongs.jpg" width="100" height="100">
<?
} //end script
?>


Thanks for the help. This site rocks!

Fuzz Martin
Pure Country 92.5 WBWI-FM Milwaukee
www.wbwifm.com






##-----------------------------------------------##
Article posted from PHP Freaks NewsGroups
http://www.phpfreaks.com/newsgroups
Get Addicted: alt.comp.lang.php
##-----------------------------------------------##
Reply With Quote
  #2 (permalink)  
Old 01-27-2004
Tom Thackrey
 
Posts: n/a
Default Re: Time Display


On 27-Jan-2004, fsrfan_at_hotmail_dot_com@foo.com (Fuzz Martin) wrote:

> This should be a simple one, yet I don't get it. I work for a radio
> station
> and I am trying to use php to post a picture of the personality on the
> air,
> only while they're on the air. I can get it to work if I don't use the
> day
> of the week, but I went through and put in a variable for the day of the
> week and now it is only showing me sunday's line up.
>
> Help me out and e-mail me your address and I will send you a t-shirt.
> (it's
> radio, that's all they give me.)
>
> Here's what I've got:
>
> <?
> $hour = date('G');
> $day = date('w');
>
> if ($day == 0 || $hour < 7) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 0 || $hour == 7 || $hour < 11) {
> ?>
> <span class="style1 style4">Crook &amp; Chase<br>8AM-Noon</
> span><br>
> <a href="crchase.php"><img src="../images/crchase.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 0 || $hour == 11 || $hour <= 23) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 1 || $hour < 5) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 1 || $hour == 5 || $hour < 9) {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 9 || $hour < 14) {
> ?>
> <span class="style1 style 4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 14 || $hour < 18) {
> ?>
> <span class="style1 style 4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 18 || $hour < 22) {
> ?>
> <span class="style1 style 4">Lia
> Knight<br>7-Midnight</span><br>
> <a href="lia.php"><img src="../images/lia_head.jpg"
> width="100"
> height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 22 || $hour <= 23) {
> ?>
> <span class="style1 style 4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../dwright.php" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour < 5) {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../dwright.php" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 5 || $hour < 9)
> {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 9 || $hour < 14)
> {
> ?>
> <span class="style1 style4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 14 || $hour <
> 18)
> {
> ?>
> <span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 18 || $hour <
> 22)
> {
> ?>
> <span class="style1 style4">Lia
> Knight<br>7-Midnight</span><br>
> <a href="lia.php"><img src="../images/lia_head.jpg"
> width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 22 || $hour
> <=23)
> {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../images/danny.gif"
> width="100"
> height="100"></a>
> <?
>
> } else if ($day == 6 || $hour < 5) {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../images/danny.gif"
> width="100"
> height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 5 || $hour < 9) {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 9 || $hour < 14) {
> ?>
> <span class="style1 sytle4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 14 || $hour < 18) {
> ?>
> <span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 18 || $hour <=23) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
> } //end script
> ?>


My guess is you have not coded your conditionals correctly. For example your
first if is
if ($day == 0 || $hour < 7) {
which says if the day is Sunday OR the hour is less than 7

This suggests that your early morning DJ not only works 7 days per week, but
a 31 hour shift on sunday.

You probably wanted
if ($day == 0 && $hour < 7) {


--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Reply With Quote
  #3 (permalink)  
Old 02-02-2004
Doug Bonomo
 
Posts: n/a
Default Re: Time Display

Played around for a few minutes, built an example for ya.

I took a totally different approach to suggest something a bit simpler to
manage. Basically what Im doing is using a simple text file which is comma
delimited. Each space between commas is a field. The fields Im using are
as follows

Day,Start hour, End Hour, Show Name, Time Slot,Page Link,Image Ref

An example row would be:
0,7,12,Morning Show,7 to Noon,mrbillshow.html,../images/mrbill.gif

so thats sunday, 7am, 12pm, and the rest is obvious.

The code can be viewed at http://ghost.3drealm.net/samples/lineup.txt and a
working copy at http://ghost.3drealm.net/samples/lineup.php

I only have a couple entries in the lineup file which is the feeder, I will
add a few more to cover more hours and such. I hope this helps you. This
method is far more manageable for future modfications as well.

Doug B.

"Fuzz Martin" <fsrfan_at_hotmail_dot_com@foo.com> wrote in message
news:7XWdnYfkkoCy4YvdRTvaKw@giganews.com...
> This should be a simple one, yet I don't get it. I work for a radio
> station
> and I am trying to use php to post a picture of the personality on the
> air,
> only while they're on the air. I can get it to work if I don't use the
> day
> of the week, but I went through and put in a variable for the day of the
> week and now it is only showing me sunday's line up.
>
> Help me out and e-mail me your address and I will send you a t-shirt.
> (it's
> radio, that's all they give me.)
>
> Here's what I've got:
>
> <?
> $hour = date('G');
> $day = date('w');
>
> if ($day == 0 || $hour < 7) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 0 || $hour == 7 || $hour < 11) {
> ?>
> <span class="style1 style4">Crook &amp; Chase<br>8AM-Noon</
> span><br>
> <a href="crchase.php"><img src="../images/crchase.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 0 || $hour == 11 || $hour <= 23) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 1 || $hour < 5) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
>
> } else if ($day == 1 || $hour == 5 || $hour < 9) {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 9 || $hour < 14) {
> ?>
> <span class="style1 style 4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 14 || $hour < 18) {
> ?>
> <span class="style1 style 4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 18 || $hour < 22) {
> ?>
> <span class="style1 style 4">Lia Knight<br>7-Midnight</span><br>
> <a href="lia.php"><img src="../images/lia_head.jpg" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 1 || $hour == 22 || $hour <= 23) {
> ?>
> <span class="style1 style 4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../dwright.php" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour < 5) {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../dwright.php" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 5 || $hour < 9) {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 9 || $hour < 14) {
> ?>
> <span class="style1 style4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 14 || $hour < 18)
> {
> ?>
> <span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 18 || $hour < 22)
> {
> ?>
> <span class="style1 style4">Lia Knight<br>7-Midnight</span><br>
> <a href="lia.php"><img src="../images/lia_head.jpg" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 2 || $day <= 5 || $hour == 22 || $hour <=23)
> {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../images/danny.gif" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 6 || $hour < 5) {
> ?>
> <span class="style1 style4">Danny Wright<br>Midnight-6AM</
> span><br>
> <a href="dwright.php"><img src="../images/danny.gif" width="100"
> height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 5 || $hour < 9) {
> ?>
> <span class="style1 style4">Mike Elliott<br>6-10AM</span><br>
> <a href="melliott.php"><img src="../images/melliott.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 9 || $hour < 14) {
> ?>
> <span class="style1 sytle4">Cat Brooks<br>10-3PM</span><br>
> <a href="cbrooks.php"><img src="../images/cbrooks.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 14 || $hour < 18) {
> ?>
> <span class="style1 style4">Fuzz Martin<br>3-7PM</span><br>
> <a href="fmartin.php"><img src="../images/fmartin.jpg"
> width="100" height="100"></a>
> <?
>
> } else if ($day == 6 || $hour == 18 || $hour <=23) {
> ?>
> <span class="style1 style4">The Better Songs</span><br>
> <img src="../images/bettersongs.jpg" width="100" height="100">
> <?
> } //end script
> ?>
>
>
> Thanks for the help. This site rocks!
>
> Fuzz Martin
> Pure Country 92.5 WBWI-FM Milwaukee
> www.wbwifm.com
>
>
>
>
>
>
> ##-----------------------------------------------##
> Article posted from PHP Freaks NewsGroups
> http://www.phpfreaks.com/newsgroups
> Get Addicted: alt.comp.lang.php
> ##-----------------------------------------------##



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:15 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0