Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 3 FirstFirst 123
Results 31 to 40 of 40
  1. #31
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    on air off air

    hi there i was just wondering if anyone has
    fully finished the code for on air off air

    as i would like one

  2. #32
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi there i had a simular sort of code

    wich is


    PHP Code:
    <?php
    $h 
    date('G'); //set variable $h to the hour of the day
    $d date('w'); //set variable $d to the day of the week.
    $year date('Y'); //set variable $year to the current year
    //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
    // Adjust 2 hour offset for MST below.
    $h $h+1;

    // MONDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 14$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 14 && $h 16$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 16 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // TUESDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 17 && $h 20$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 20$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // WEDNESDAY SCHEDULE
    else if ($d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 22 && $h 00$img 'images2/dj/images/djultra.jpg';
    else if (
    $d == && $h >= && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // THURSDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 16 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // FRIDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 10$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 10 && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 15 && $h 18$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 18 && $h 20$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 20 && $h 22$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 22$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // SATURDAY SCHEDULE
    else if ($d == && $h >= && $h 22$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 22 && $h 00$img 'images2/dj/images/djultra.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 9$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 10$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 13 && $h 14$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 14 && $h 15$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 16 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 19 && $h 22$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 22$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';

    // SUNDAY SCHEDULE
    else if ($d == && $h >= && $h 2$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 4$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 5$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 6$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 8$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 9$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= && $h 10$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 12 && $h 16$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 16 && $h 17$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 17 && $h 18$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 18 && $h 19$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 19 && $h 21$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h >= 21$img 'images2/dj/images/autodj.jpg';
    else if (
    $d == && $h 0$img 'images2/dj/images/autodj.jpg';
    ?>

    <html>
    <head></head>
    <body>
    <p align="center"><img src="<?php echo $img?>"> </p>
    </body>
    </html>
    <p>&nbsp;</p>
    but this don't work for me? so i was wondering if anyone has a fully finished code like chucks one
    Last edited by VIPStephan; 03-06-2013 at 04:11 AM. Reason: added code BB tags

  3. #33
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,418 Times in 4,383 Posts
    Ummm...what is the point of your code? *ALL* of your images are the same: 'images2/dj/images/autodj.jpg'
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  4. #34
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,418 Times in 4,383 Posts
    And your code will never work, because of this:
    Code:
    $h = date('G'); //set variable $h to the hour of the day
    $h = $h+1;
    So now your $h value will be 1 through 24, *NOT* 0 through 23.

    Which doesn't match up at all with the if conditions you are using.

    Also, because you are doing this in PHP code, the image won't change when the hour changes, if the user still has the page open in his/her browser.

    May I suggest you start a *NEW THREAD*, instead of piggy backing on this old one? And state explicitly what you are trying to do?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  5. #35
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks ive posted in a seprate forum over at
    http://www.codingforums.com/showthre...38#post1317938

  6. #36
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,091
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    You can put your PHP code back into this example, but I saw no particular need for it using JS only.

    Note your logic can be vastly compressed with a bit of forethought...
    The value of $h (hours) can only be within the range of 0..23 in military time.
    Therefore all you need to do is check for $h < hour starting a midnight and staying sequential in your test logic.

    Also, you only need to check for the day once and not each and every time.
    If the schedule stays the same for any one or more days, the logic could be compressed further.

    Substitute your own path and image file names into the appropriate lines
    and ask questions about the following logic if it does not make sense to you...
    Code:
    <html>
    <head>
    <title> DJ times </title>
    </head>
    <body>
    <div id="DJtimes">
     <img id="DJpix" src="" title='No show' alt="No show" style="font-size:3em; background-color:orange">
    </div>
    
    <script type="text/javascript">
    function DJdisplay() {
     var now = new Date();
     var $d = now.getDay();
    
     var $h = now.getHours();  // adjust for MST if necessary or use UTC time
    // var $h = now.getMinutes();  // for testing purposes only before hh:24
    
     var $year = now.getFullYear();
    
     var baseURL = 'http://www.nova.edu/hpd/otm/pics/4fun/';  // change to: './images2/dj/images/
     var $img = document.getElementById('DJpix');
    
    /*
     $h = date('G'); //set variable $h to the hour of the day
     $d = date('w'); //set variable $d to the day of the week.
     $year = date('Y'); //set variable $year to the current year
    //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
    // Adjust 2 hour offset for MST below.
     $h = $h+1;
    */
    
     if ($d == 1) {  // MONDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'11.jpg'
      else if ($h < 12) $img.src = baseURL+'12.jpg'
      else if ($h < 14) $img.src = baseURL+'13.jpg'
      else if ($h < 16) $img.src = baseURL+'13.jpg'
      else if ($h < 19) $img.src = baseURL+'14.jpg'
      else if ($h >= 19) $img.src = baseURL+'15.jpg';
     }
    
     if ($d == 2) {  // TUESDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'21.jpg'
      else if ($h < 12) $img.src = baseURL+'22.jpg'
      else if ($h < 13) $img.src = baseURL+'23.jpg'
      else if ($h < 15) $img.src = baseURL+'23.jpg'
      else if ($h < 17) $img.src = baseURL+'24.jpg'
      else if ($h < 20) $img.src = baseURL+'25.jpg'
      else if ($h >= 20) $img.src = baseURL+'21.jpg';
     }
    
     if ($d == 3) {  // WEDNESDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'31.jpg'
      else if ($h < 12) $img.src = baseURL+'32.jpg'
      else if ($h < 13) $img.src = baseURL+'33.jpg'
      else if ($h < 15) $img.src = baseURL+'33.jpg'
      else if ($h < 17) $img.src = baseURL+'34.jpg'
      else if ($h < 20) $img.src = baseURL+'35.jpg'
      else if ($h >= 20) $img.src = baseURL+'31.jpg';
     }
    
     if ($d == 4 ) {  // THURSDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'41.jpg'
      else if ($h < 12) $img.src = baseURL+'42.jpg'
      else if ($h < 13) $img.src = baseURL+'43.jpg'
      else if ($h < 15) $img.src = baseURL+'43.jpg'
      else if ($h < 17) $img.src = baseURL+'44.jpg'
      else if ($h < 20) $img.src = baseURL+'45.jpg'
      else if ($h >= 20) $img.src = baseURL+'41.jpg';
     }
    
     if ($d == 5) {  // FRIDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'51.jpg'
      else if ($h < 12) $img.src = baseURL+'52.jpg'
      else if ($h < 13) $img.src = baseURL+'53.jpg'
      else if ($h < 15) $img.src = baseURL+'53.jpg'
      else if ($h < 17) $img.src = baseURL+'54.jpg'
      else if ($h < 20) $img.src = baseURL+'55.jpg'
      else if ($h >= 20) $img.src = baseURL+'51.jpg';
     }
    
     if ($d == 6) {  // SATURDAY SCHEDULE
           if ($h < 5) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'11.jpg'
      else if ($h < 9) $img.src = baseURL+'21.jpg'
      else if ($h < 10) $img.src = baseURL+'31.jpg'
      else if ($h < 11) $img.src = baseURL+'41.jpg'
      else if ($h < 12) $img.src = baseURL+'51.jpg'
      else if ($h < 13) $img.src = baseURL+'11.jpg'
      else if ($h < 14) $img.src = baseURL+'21.jpg'
      else if ($h < 15) $img.src = baseURL+'31.jpg'
      else if ($h < 17) $img.src = baseURL+'41.jpg'
      else if ($h < 19) $img.src = baseURL+'51.jpg'
      else if ($h < 22) $img.src = baseURL+'11.jpg'
      else if ($h >= 22) $img.src = baseURL+'21.jpg';
     }
    
     if ($d == 0) { // SUNDAY SCHEDULE
           if ($h < 2) $img.src = baseURL+''
      else if ($h < 4) $img.src = baseURL+'11.jpg'
      else if ($h < 5) $img.src = baseURL+'21.jpg'
      else if ($h < 6) $img.src = baseURL+'31.jpg'
      else if ($h < 8) $img.src = baseURL+'41.jpg'
      else if ($h < 9) $img.src = baseURL+'51.jpg'
      else if ($h < 10) $img.src = baseURL+'11.jpg'
      else if ($h < 11) $img.src = baseURL+'21.jpg'
      else if ($h < 12) $img.src = baseURL+'31.jpg'
      else if ($h < 16) $img.src = baseURL+'41.jpg'
      else if ($h < 17) $img.src = baseURL+'51.jpg'
      else if ($h < 18) $img.src = baseURL+'11.jpg'
      else if ($h < 19) $img.src = baseURL+'21.jpg'
      else if ($h < 21) $img.src = baseURL+'31.jpg'
      else if ($h >= 21) $img.src = baseURL+'41.jpg';
     }
    }
    
    window.onload = function () {
      DJdisplay();
      var interval = 60*60*1000;  // 1 hour checks
    //  var interval = 60*100;      // 1 minute checks for testing purposes only
      var t = setInterval("DJdisplay()",interval);
    }
    </script>
    
    </body>
    </html>

  7. #37
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,418 Times in 4,383 Posts
    See the other thread, jmrker.

    The problem with doing it in PHP only is that it won't change if the user has his/her browser open and sitting on the site at the time a "shift" changes.

    See my solution all in JS code except for being fed the base time from the server.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  8. #38
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,091
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Quote Originally Posted by Old Pedant View Post
    See the other thread, jmrker.

    The problem with doing it in PHP only is that it won't change if the user has his/her browser open and sitting on the site at the time a "shift" changes.

    See my solution all in JS code except for being fed the base time from the server.
    I did not use the PHP solution, I used the setInterval() command instead.
    If the page is open, the image does change.

    I'll post my comment above to the new thread.

  9. #39
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,418 Times in 4,383 Posts
    Whoops. Teach me not to read your entire post! Mea maxima culpa.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  10. #40
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi there i'm on the air wednesdays and sundays

    8pm till 10pm doing the 80's shows? now is this
    code rite.

    if (dy == 8) { //Wednesday Shows
    if (hh >=8 && 22 <= 1) {show ="ultra</A><BR><A></A><BR><A>80's music : </A><BR><A>ultra 80's music"}


 
Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •