PDA

View Full Version : If else



fer
02-15-2009, 02:10 AM
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

$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:)

Nile
02-15-2009, 02:17 AM
Works fine for me...Are you sure theres not a conflicting script on the page? Do you have a link to your page?

fer
02-15-2009, 02:43 AM
Hi thanks for your help


<?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

Nile
02-15-2009, 02:50 AM
Try this:


<?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']);
}
?>

fer
02-15-2009, 02:59 AM
Don't need the path to the files!

Nile
02-15-2009, 03:01 AM
What do you mean?

fer
02-15-2009, 03:04 AM
For example I use this path

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


domingo -Portuguese = Sunday

Nile
02-15-2009, 03:06 AM
What would you use the path for?

fer
02-15-2009, 03:14 AM
Yap,

Right

I can put the files in the root.

fer
02-15-2009, 03:16 AM
The code are to show a different photo every day.Something like a photo of the day

Nile
02-15-2009, 03:16 AM
You can just do:


<?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']);
}
?>

fer
02-15-2009, 03:43 AM
Thanks
Works,

But,today show the file from saturday.

Nile
02-15-2009, 03:53 AM
I'm glad to help you fer! Your welcome!

What do you mean by "but, today show the file from saturday?"

fer
02-15-2009, 04:13 AM
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

fer
02-15-2009, 04:34 AM
It's possible make same changes in this code to change at 00:00 am portuguese hour.

Nile
02-15-2009, 04:37 AM
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)

fer
02-15-2009, 04:50 AM
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 :|

Nile
02-15-2009, 01:27 PM
Ok, I'll see what I can do, but should it use Monday, Tuesday, *day, for other time zones?

fer
02-16-2009, 10:01 AM
Hi,

The code work's good.
Thanks,

I only need the Portuguese time zone.More 6 hours.

Thanks for your great help.

fer
02-16-2009, 01:03 PM
I will try this code to see if work's.


putenv('TZ=Europe/Lisbon');