SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A monthly based echo?

    I want to echo a different peice of text each month, from a present list of dates, etc. Its like a monthly calendar, but without the calendar functions... Here is what I mean:

    For example, on January, this text would be echo'ed:
    The month of Sleeping
    • Jan 3rd - Aisha Day
    • Jan 11th - Festival of Buzz. (Buzz Day)
    • Jan 16th - Elephante Day
    • Jan 29th - Kacheek Day
    How would I do this? Does anyone know of any scripts that could do that?
    Content Writing Service - Get custom SEO articles for 10$

  2. #2
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've done something similar to display a themed logo depending on the date.
    I had an include with an array of dates and logos as key value pairs. I then checked for the key (date) and if it existed showed the corresponding logo.
    More simply, you could just have a series of if or switch controls to check the date

  3. #3
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could anyone give me a working example?
    Content Writing Service - Get custom SEO articles for 10$

  4. #4
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got this strange error...:

    Warning: Compilation failed: range out of order in character class at offset 667 in c:\apache\www\func.php on line 69
    Content Writing Service - Get custom SEO articles for 10$

  5. #5
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an example, simplified, without any fancy switch controls or arrays etc.

    PHP Code:
    $message ""$today date("dm"); // 3010 
     
    if($today=="1703"

    $message "Happy St. Patrick's Day"

    else if(
    $today=="3110"

    $message ="Boo! Happy Halloween"

    /* add your own special dates */ 
    /* default */
    else 

    $message "Hi, nothing special today"

    echo 
    $message

  6. #6
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And what about a full month, instead of just one day?
    Content Writing Service - Get custom SEO articles for 10$

  7. #7
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    take a look at the php date function

  8. #8
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhhh.... ??
    Content Writing Service - Get custom SEO articles for 10$

  9. #9
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // Default string
    $s_default 'Not a cool month';
    // Add your data here
    $a_events = array(=> 'Cool month'
                      
    => 'Even cooler',
                      
    => 'The coolest');
    // Print out the string
    echo (isset($a_events[date('n')])) ? $a_events[date('n')] : $s_default

  10. #10
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you need a default string?
    Content Writing Service - Get custom SEO articles for 10$

  11. #11
    Ceci n'est pas Zoef Zoef's Avatar
    Join Date
    Nov 2002
    Location
    Malta
    Posts
    1,111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the months you don't (or forget to) offer a 'cool' string.
    English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac

  12. #12
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That makes sense...
    Content Writing Service - Get custom SEO articles for 10$

  13. #13
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, Zoef got it right.

  14. #14
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice! Your script did just what I needed! Thanks!
    Content Writing Service - Get custom SEO articles for 10$


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
  •