this is a script that changes the colour of the background to the day of the week, the code uses if and elseif...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <?php
// A list of the days of the week.
$name_day = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
foreach ($name_day as $name);
{
if ($name == "Sunday")
{ // if day is Sunday background color is - Green.
$background_color = "Green";
}
elseif ($name == "Monday")
{
$background_color = "#ff9966";
}
elseif ($name == "Tuesday")
{
$background_color = "#cccc33";
}
elseif ($name == "Wednesday")
{
$background_color = "#999900";
}
elseif ($name == "Thursday")
{
$background_color = "#66cc33";
}
elseif ($name == "Friday")
{
$background_color = "#cc0000";
}
elseif ($name == "Saturday")
{ // if day is not Sunday, but day is Saturday background color is - Purple.
$background_color = "ff66ff";
}
}
$name_of = date("d-l-y"); // date, day, year.
echo "$name_of";
?>
|
Great job Senor Fenech! This will be useful in creating my calendar widget for my sie. Thanks a lot and keep up the great work.