Results 1 to 7 of 7
  1. #1

    Default Need a little help with PHP timed content


    Hi, I have this timed content PHP script for my online radio to show the pictures of DJs on their specific times. My issue is how to set specific day like only Mon-Fri or MWF and etc.

    Thanks in advance.

    <?php

    date_default_timezone_set('Asia/Manila');

    $h = date('G'); //set variable $h to the hour of the day
    if ($h < 9) $img = 'autodj.jpg';
    else if ($h <11) $img = 'blue.jpg';
    else if ($h <15) $img = 'koki.jpg';
    else if ($h < 20) $img = 'jaycee.jpg';
    else if ($h < 24) $img = 'dory.jpg';
    else $img = 'autodj.jpg';


    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
    "http://www.w3.org/TR/html4/frameset.dtd">
    <HTML>
    <meta http-equiv="refresh" content="120;url=index.php">
    <HEAD>
    <TITLE>RP DJ on Board</TITLE>
    </HEAD>
    <body>
    <p align="center">
    You're with<br />
    <img src="<?php echo $img; ?>">
    </body>
    </p>
    </HTML>

  2. #2

    Default Re: Need a little help with PHP timed content

    how bout i store nimo ang images sa array bro then ang index lang imong duwaan?

  3. #3
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018

    Default Re: Need a little help with PHP timed content

    Code:
    $day = date('D');
    
    switch( $day ){
        case 'Mon':
        $img = 'autodj.jpg';
        break;
        case 'Tue':
        $img = 'blue.jpg';
        break;
        case 'Wed':
        $img = 'koki.jpg';
        break;
        case 'Thu':
        $img = 'jaycee.jpg';
        break;
        case 'Fri':
        $img = 'dory.jpg';
        break;
    
    }
    Reference: PHP: date - Manual
    Last edited by Klave; 07-05-2012 at 04:11 PM.

  4. #4

    Default Re: Need a little help with PHP timed content

    Quote Originally Posted by moodsey211 View Post
    how bout i store nimo ang images sa array bro then ang index lang imong duwaan?
    naa kay sample boss?

  5. #5

    Default Re: Need a little help with PHP timed content

    Quote Originally Posted by Klave View Post
    Code:
    $day = date('D');
    
    switch( $day ){
        case 'Mon':
        $img = 'autodj.jpg';
        break;
        case 'Tue':
        $img = 'blue.jpg';
        break;
        case 'Wed':
        $img = 'koki.jpg';
        break;
        case 'Thu':
        $img = 'jaycee.jpg';
        break;
        case 'Fri':
        $img = 'dory.jpg';
        break;
    
    }
    Reference: PHP: date - Manual
    salamat boss. but ang ako unta gipangita is like dory's sched is 8pm-12mn Mon thru Sat and same for other djs. naa sila specific time ug days.

  6. #6

    Default Re: Need a little help with PHP timed content

    Supposing naa kay array like this one:

    Code:
    $images = array('Mon' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'),
                    'Tue' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'),
                    'Wed' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'));
    Then to find the current image maghimo ka ug function nga something like this:

    Code:
    function current_dj()
    {
        global $images;
    
        $day = date('D');
        $time = date('G');
    
        $img = '';
    
        /* Check what day today is. */
        if(isset($images[$day])) {
            /* Check if we have a DJ for the specified hour. */
            if(isset($images[$day][$time])) {
                $img = $v;
            } else {
                foreach(array_reverse($images[$day], TRUE) as $k => $v) {
                    if($k < $time) {
                        $img = $v;
                        break;
                    }
                }
            }
        }
    
        return $img;
    }
    Then experiment lang sa katong array.

  7. #7

    Default Re: Need a little help with PHP timed content

    Ako ni testingan. Salamat boss.

    I'll report back if matest na nako.

    Quote Originally Posted by moodsey211 View Post
    Supposing naa kay array like this one:

    Code:
    $images = array('Mon' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'),
                    'Tue' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'),
                    'Wed' => array(0  => 'autodj.jpg',
                                   9  => 'blue.jpg',
                                   11 => 'kokj.jpg',
                                   15 => 'jaycee.jpg',
                                   20 => 'dory.jpg'));
    Then to find the current image maghimo ka ug function nga something like this:

    Code:
    function current_dj()
    {
        global $images;
    
        $day = date('D');
        $time = date('G');
    
        $img = '';
    
        /* Check what day today is. */
        if(isset($images[$day])) {
            /* Check if we have a DJ for the specified hour. */
            if(isset($images[$day][$time])) {
                $img = $v;
            } else {
                foreach(array_reverse($images[$day], TRUE) as $k => $v) {
                    if($k < $time) {
                        $img = $v;
                        break;
                    }
                }
            }
        }
    
        return $img;
    }
    Then experiment lang sa katong array.

  8.    Advertisement

Similar Threads

 
  1. need help with php
    By snowleopard in forum Websites & Multimedia
    Replies: 5
    Last Post: 12-01-2011, 08:49 AM
  2. a little help with .htaccess please. :)
    By emailroy2002 in forum Programming
    Replies: 5
    Last Post: 01-28-2009, 05:25 PM
  3. Help with PHP Login Stuff
    By poymode in forum Programming
    Replies: 36
    Last Post: 06-20-2008, 07:57 AM
  4. Need a Little Help about Internet
    By goryo85 in forum Networking & Internet
    Replies: 6
    Last Post: 04-25-2007, 07:21 PM
  5. VB Guros need a little help
    By legal_cd in forum Programming
    Replies: 2
    Last Post: 09-08-2006, 01:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top