-
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:)
-
Works fine for me...Are you sure theres not a conflicting script on the page? Do you have a link to your page?
-
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
-
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']);
}
?>
-
Don't need the path to the files!
-
-
For example I use this path
include('/hsphere/local/home/makukulo/fotogenicos.net/seleccao/byremus/domingo.html');
domingo -Portuguese = Sunday
-
What would you use the path for?
-
Yap,
Right
I can put the files in the root.
-
The code are to show a different photo every day.Something like a photo of the day
-
You can just do:
PHP 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("/hsphere/local/home/makukulo/fotogenicos.net/seleccao/byremus/".$includes[$day]);
} else {
include("/hsphere/local/home/makukulo/fotogenicos.net/seleccao/byremus/".$includes['Default']);
}
?>
-
Thanks
Works,
But,today show the file from saturday.
-
I'm glad to help you fer! Your welcome!
What do you mean by "but, today show the file from saturday?"
-
Thanks,
I'm forgot ,the server have the time zone from New york and I'm in Portugal/Lisbon more 5 hours and is Sunday. :)
Thanks for your help
Fernando
-
It's possible make same changes in this code to change at 00:00 am portuguese hour.
-
Instead of using days you want it to change at 00:00 AM portuguese hour? Is that what you want(sorry, I didn't fully understand)
-
Yap,my english is very poor.Sorry
For example
Now, the script just include the file from sunday at 5:00 am portuguese hour.My question is,it's possible same code because the time difference between the time server and local time.
Hope you understand :|
-
Ok, I'll see what I can do, but should it use Monday, Tuesday, *day, for other time zones?
-
Hi,
The code work's good.
Thanks,
I only need the Portuguese time zone.More 6 hours.
Thanks for your great help.
-
I will try this code to see if work's.
PHP Code:
putenv('TZ=Europe/Lisbon');