php - Change background color of webpage according to day of the week -


i want change background color of homepage based on day of week.

for example :

on sunday , monday , tuesday want change background of homepage blue .

on thursday want change gray . on friday yellow , on saturday should change green .

i have tried following code on website ,but doesn't seem work ,my background color not changing, tried replace value of $day name of week

 $day="monday"; 

but didn't work.

here code

 $day=date("l");  if($day =="sunday")  {$bg_color="blue";}  if($day =="monday")  {$bg_color="blue";}   if($day =="tuesday")  {$bg_color="blue";}    if($day =="thursday")  {$bg_color="gray";}    if($day =="friday")  {$bg_color="yellow";}    if($day =="saturday")  {$bg_color="green";}    echo "<div style='background-color:$bg_color>welcome homepage</div>";  

try this. works me. (whenever have many if conditions have, think using switch, instead.

<?php $day=date("l");  switch($day) {     case 'monday':         $bg_color = "red";         break;     case 'tuesday':         $bg_color = "blue";         break;     case 'wednesday':         $bg_color = "blue";         break;     case 'thursday':         $bg_color = "gray";         break;     case 'friday':         $bg_color = "yellow";         break;     case 'saturday':         $bg_color = "green";         break;     case 'sunday':     default:         $bg_color = "black";         break; }  echo "<div style='background-color:$bg_color'>welcome homepage</div>"; 

your issue:

** code had missing closing single quote ' style


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -