Change Background Color using php - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Change Background Color using php (/showthread.php?tid=1379) Pages:
1
2
|
Change Background Color using php - immi - 10-13-2009 Hello Keep enjoy using great SF forum SCRIPT DESCRIPTION: -------------------- This changes the colour of the background depending on the day of the week! Just place this after the (/head tag) and before the (body) tag (which you will have to take out) With this code you can make your page more attractive, by having random colors. CODE: ----------- PHP Code: <? And change the <body> tags with the following code: PHP Code: <body bgcolor="<? print ($bgcolor[$today] - 1);?>"> --- That's it Enjoy RE: Change Background Color using php - El Zorro - 10-13-2009 how does it now what day it is? RE: Change Background Color using php - Gaijin - 10-13-2009 (10-13-2009, 03:53 PM)El Zorro Wrote: how does it now what day it is? The date() function used witht the parameter "w" returns the number of a day (1-7), that is then used to ouput right member of $bgcolor array @OP You may want to consider this line as false. PHP Code: <body bgcolor="<?print("$bgcolor[$today]");?>"> The first element of an array is always = 0, so your line will never use the first member "#FF0000" The solution is PHP Code: <body bgcolor="<? print ($bgcolor[$today] - 1);?>"> RE: Change Background Color using php - R3c0nna1ssanc3 - 10-13-2009 Thanks for this im really bad at php and I love to learn new things about it. what is this part for? $today = date("w"); edit: never mind I get it now RE: Change Background Color using php - immi - 10-14-2009 (10-13-2009, 04:31 PM)NinjaGeek Wrote: @OP Yes you are right actually, I have edited the line in FP also RE: Change Background Color using php - Gaijin - 10-14-2009 (10-14-2009, 03:14 AM)immi Wrote: Yes you are right actually, I have edited the line in FP also np mate .... I lkie that you use date("w") and then directly access the array, I've seen so many people doing if and switches to get this little script to work RE: Change Background Color using php - immi - 10-14-2009 (10-14-2009, 03:18 AM)NinjaGeek Wrote: I lkie that you use date("w") and then directly access the array, I've seen so many people doing if and switches to get this little script to work Yours welcome ;) RE: Change Background Color using php - Gaijin - 10-14-2009 (10-14-2009, 03:25 AM)immi Wrote: Yours welcome ;) And I had an idea based on this script..... Changes the color based on the four seasons PHP Code: function fourSeasons() { RE: Change Background Color using php - immi - 10-14-2009 (10-14-2009, 03:51 AM)NinjaGeek Wrote: And I had an idea based on this script..... Changes the color based on the four seasons Nice idea. RE: Change Background Color using php - Gaijin - 10-14-2009 (10-14-2009, 06:18 AM)immi Wrote: Nice idea. Yeah, but now you'll get that ugly brown I've put up there.. look at it in the winter or spring... nice colors. |