Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Display different image each hour of the day (based on server time)

  1. #11
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there, im using this php script and i want to add minutes on the script but i have a problem when the radio programs last more than an hour the script just doesnt show anything after that minute comes.

    Code:
    <?php
    $hora = date('G'); // Horas de 0 a 23
    $dia = date('w'); // Dias 0 (Domingo) a 6 (Sabado)
    $minuto = date('i'); // Minutos de 00 a 59
    
    $hora = $hora+1;
    $minuto = $minuto+21;
    
    // MARTES
    if ($dia == 2 && $hora >= 0 && $hora < 4) $img = 'images/yaco.gif';
    else if ($dia == 2 && $hora >= 4 && $hora < 8) $img = 'images/nancy.gif';
    else if ($dia == 2 && $hora >= 8 && $hora < 12) $img = 'images/lucas.gif';
    else if ($dia == 2 && $hora >= 12 && $hora < 13) $img = 'images/juan.gif';
    else if ($dia == 2 && $hora >= 13 && $hora < 15) $img = 'images/henoch.gif';
    else if ($dia == 2 && $hora >= 15 && $hora < 17) $img = 'images/gustavo.gif';
    else if ($dia == 2 && $hora >= 17 && $hora <= 21 && $minuto <= 44) $img = 'images/edmundo.gif';
    ?>
    
    <html>
    <head></head>
    <body>
    	
    Estas escuchando a...
    
    <br><br>
    
    <img src="<?php echo $img; ?>">
    
    </body>
    </html>
    can you guys help me please? thanks in advance!

  2. #12
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Bringing back the dead...

    Hi,

    This post is old but...

    I just came across this script and it's almost exactly what I need, but I'm also interested in adding minutes as my schedule changes on the mid point of some hours.

    If anyone can help, I would appreciate it greatly. I would even pay you a bit for you time.

    Thanks.

  3. #13
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    would it be possible for this code to be made in to html or css? if so would someone please help me to do it as I dont know how.

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,781
    Thanks
    223
    Thanked 657 Times in 645 Posts

    Default

    HTML and CSS don't allow for conditional ("if") statements. No. You need Javascript, or a serverside programming language like PHP, ASP, CGI, etc.
    (Of course any of those can be combined with HTML and CSS as needed to create the desired look.)
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  5. #15
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hello thanks for your reply,

    the problem I have is I can not upload PHP to my host, but JS etc I can, would it be possible for you to help me make this into a JS code by any chance?

  6. #16
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,781
    Thanks
    223
    Thanked 657 Times in 645 Posts

    Default

    I should clarify something: you can do this in Javascript, but you cannot base it on server time. It will be based on the user's time on their computer (even if it is wrong or in a different location). You might be able to use Javascript to make it relative to the right timezone (adjust based on the current timezone) if that information is available. I'm not sure.

    But if you google "change image every hour javascript" you will find some information. Please do a search first.

    If your specific question is about the server time, then, no, you must have a serverside language like PHP available. You can do everything else in Javascript, but not the server time.
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  7. #17
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need exactly the same but....

    Quote Originally Posted by yrrot View Post
    Hi Everyone,
    Thanks for all your help on this one. I succesfully got this working on the new site I'm creating. I needed to display a different image for each radio host at different points throughout the day, each day of the week. I also had to include a 2 hour offset from the server's time to match my time zone. Here's what my final code looks like.

    Hopfully this is helpfule to others looking to do the same thing.

    Regards,
    Torry

    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-2;

    // MONDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // TUESDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 17 && $h 20$img 'img/hosts/westmar.jpg';
    else if (
    $d == && $h >= 20$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // WEDNESDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // THURSDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // FRIDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 10 && $h 12$img 'img/hosts/patm.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/edp.jpg';
    else if (
    $d == && $h >= 15 && $h 18$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 18 && $h 20$img 'img/hosts/jeremyb.jpg';
    else if (
    $d == && $h >= 20 && $h 22$img 'img/hosts/exfyl.jpg';
    else if (
    $d == && $h >= 22$img 'img/hosts/stickyb.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/stickyb.jpg';

    // SATURDAY SCHEDULE
    else if ($d == && $h >= && $h 4$img 'img/hosts/techtronic.jpg';
    else if (
    $d == && $h >= && $h 5$img 'img/hosts/pmw.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/geoffh.jpg';
    else if (
    $d == && $h >= && $h 9$img 'img/hosts/tomf.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/jimmyj.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'img/hosts/jasonr.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'img/hosts/hollyk.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/tomt.jpg';
    else if (
    $d == && $h >= 13 && $h 14$img 'img/hosts/seanf.jpg';
    else if (
    $d == && $h >= 14 && $h 15$img 'img/hosts/nutmeg.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'img/hosts/aaron_jenny.jpg';
    else if (
    $d == && $h >= 17 && $h 19$img 'img/hosts/rayg_adrians.jpg';
    else if (
    $d == && $h >= 19 && $h 22$img 'img/hosts/mattb.jpg';
    else if (
    $d == && $h >= 22$img 'img/hosts/hairballj.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/hairballj.jpg';

    // SATURDAY SCHEDULE
    else if ($d == && $h >= && $h 2$img 'img/hosts/darrelm.jpg';
    else if (
    $d == && $h >= && $h 4$img 'img/hosts/techtronic.jpg';
    else if (
    $d == && $h >= && $h 5$img 'img/hosts/bigjon.jpg';
    else if (
    $d == && $h >= && $h 6$img 'img/hosts/joebear.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/russh.jpg';
    else if (
    $d == && $h >= && $h 9$img 'img/hosts/ronk.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/rockpoint.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'img/hosts/churchatqc.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'img/hosts/desertcf.jpg';
    else if (
    $d == && $h >= 12 && $h 16$img 'img/hosts/kristenm.jpg';
    else if (
    $d == && $h >= 16 && $h 17$img 'img/hosts/cdogg.jpg';
    else if (
    $d == && $h >= 17 && $h 18$img 'img/hosts/snarf_daff.jpg';
    else if (
    $d == && $h >= 18 && $h 19$img 'img/hosts/sonicsociety.jpg';
    else if (
    $d == && $h >= 19 && $h 21$img 'img/hosts/jscott.jpg';
    else if (
    $d == && $h >= 21$img 'img/hosts/ghostlytalk.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/ghostlytalk.jpg';
    ?>
    this covers what i would like it to do but im stuck on how to make it more dynamic?
    id like it to run via mysql so that a form to edit all its details is possible on another page..
    so i can select what dj at what time is playing.. or add another dj to the schedule

    can any one please help?

  8. #18
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,496
    Thanks
    16
    Thanked 223 Times in 222 Posts
    Blog Entries
    1

    Default

    Do you have much experience with php/MySQL?

    If you have the basis for your HTML form, and have some experience with php/MySQL then this might be something that somebody here can guide you on.

    However, if you have no experience and require somebody to code this for you as a custom application, it will probably need to be taken to the paid work requests forum : http://www.dynamicdrive.com/forums/f...-Work-Requests
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) |
    The only limit to creativity is imagination: JemCon.org

Bookmarks

Posting Permissions

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