MyBB Community Forums

Full Version: Random BG per refresh
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there,
I've followed the following 'tutorial'; https://css-tricks.com/snippets/php/rand...und-image/
Unfortunately, couldn't get it to work.

I put the following code in global.php



//Random BG
  $bg = array('bg_1.png', 'bg_2.png', 'bg_3.png', 'bg_4.png', 'bg_5.png', 'bg_6.png', 'bg_7.png' ); // array of filenames

  $i = rand(0, count($bg)-1); // generate random number size of the array
  $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
And the following CSS in headerinclude


<style type="text/css">
<!--
body{
background: url(images/<?php echo $selectedBg; ?>) no-repeat;
}
-->
</style>

Nothing appears on the body tag.
I can't give the forums link yet, though.
Any idea ? Thanks.

Problem solved, thanks though.