Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can try something like:</p> <pre><code>&lt;?php $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // 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 ?&gt; </code></pre> <p><strong>CSS (in the head)</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;style type="text/css"&gt; &lt;!-- body{ background: url(images/&lt;?php echo $selectedBg; ?&gt;) no-repeat; } --&gt; &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- website --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>Edit (user's comments)</strong></p> <pre><code>&lt;?php $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // 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 ?&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset=utf-8&gt; &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt; &lt;title&gt;Start Page&lt;/title&gt; &lt;style type="text/css"&gt; &lt;!-- body{ background: url(images/&lt;?php echo $selectedBg; ?&gt;) no-repeat; } --&gt; &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="one"&gt;01 &lt;div class="title"&gt;General&lt;/div&gt; &lt;div class="links"&gt; &lt;a href="google.com"&gt;Google &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload