Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: If else

  1. #1
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question If else

    Hi,

    Can you help me.Please

    I need a script to a include a different file every days of the week.

    Tried this,but don't work.

    PHP Code:
    <?php

    $d
    =date("D");
    if (
    $d=="Mon")
      include (
    'algo.html');
    elseif (
    $d=="Tue")
      include (
    'algo2.html');

    ?>
    The code are to use in SMF.
    What's wrong.

    Sorry my english

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Works fine for me...Are you sure theres not a conflicting script on the page? Do you have a link to your page?
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hi thanks for your help

    PHP Code:
    <?php 

    $d
    =date("D"); 
    if (
    $d=="Sun"
      include (
    'algo.html'); 
    else
      include (
    'algo2.html'); 

    ?>
    I treid this and works but don't include the file of Sunday,just show the algo2.html

    My page www.fotogenicos.net

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    <?php
    $includes = array(
    "Monday" => "monday.html",
    "Tuesday" => "tuesday.html",
    "Wednesday" => "wednesday.html",
    "Thursday" => "thursday.html",
    "Friday" => "friday.html",
    "Saturday" => "saturday.html",
    "Default" => "default.html"
    );
    $day = ucfirst(date('l'));
    if(isset($includes[$day])){
    	include($includes[$day]);
    } else {
    	include($includes['Default']);
    }
    ?>
    Last edited by Nile; 02-15-2009 at 03:02 AM.
    Jeremy | jfein.net

  5. The Following User Says Thank You to Nile For This Useful Post:

    fer (02-15-2009)

  6. #5
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Don't need the path to the files!

  7. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What do you mean?
    Jeremy | jfein.net

  8. #7
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    For example I use this path

    include('/hsphere/local/home/makukulo/fotogenicos.net/seleccao/byremus/domingo.html');


    domingo -Portuguese = Sunday

  9. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What would you use the path for?
    Jeremy | jfein.net

  10. #9
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Yap,

    Right

    I can put the files in the root.

  11. #10
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    The code are to show a different photo every day.Something like a photo of the day

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
  •