PDA

View Full Version : Habbling.com - NEEDS YOU



DJCoopster
26-02-2006, 09:38 AM
Habbling Version 6 is coming soon...

We have one problem though. We are making the background of the site change everytime you reload. And need 3 different Backgrounds of things like Trees, Hills, Buildings and things like that.

OR...

We need 1 background which is in Day and then in Night. So we can code it so it changes with the user's computer clock.

If you think in ANY way you could help, reply :)

Thanks,
Ultimative

timROGERS
26-02-2006, 09:46 AM
Here you go, this should do it. Put this at the top:


<?php
$number = rand(1, 3);
if ($number == "1")
$background = "first background URL";
if ($number == "2")
$background = "second background URL";
if ($number == "3")
$background = "third background URL";
?>

Then in the CSS where the background goes put this:


<?php echo $background; ?>

DJCoopster
26-02-2006, 09:50 AM
Cheers, anyone able to design the Backgrounds then?

timROGERS
26-02-2006, 09:54 AM
I'm not really a graphics designer type :P I just write the PHP :P

J!
26-02-2006, 10:19 AM
Err, if your wanting the code to change backrounds depending on day or night, thats not the one for you. I can write a code on here for a different image every day of the week, but i have never worked with time in javascript before.



<BODY>

<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();
arday = new Array("sunday.gif", "monday.gif", "tuesday.gif",
"wednesday.gif", "thursday.gif", "friday.gif", "saturday.gif");

document.write("<body background='" + arday[day] + "'>");
</script>


I think that will work, im not too experienced in javascript, but i dont have a clue how to emulate that to php [although i can code in php, just ive never bothered with time in both of the languages.

timROGERS
26-02-2006, 10:21 AM
Thats not a good way to do it J!, you shouldn't use body background, you should use CSS :P If he wants it I can do a time based one though :P

Want to hide these adverts? Register an account for free!