PDA

View Full Version : Help inserting random image in header


kersti
09-06-2010, 09:44 AM
Hi
I want to include a random image next to the name on my header and I'm havingtrouble getting it to work.

This is the code I have in the header file

<li><img src="http://www.domain.com/images/icons/smile"<?php $random = rand(1,9); echo $random; ?>".gif" alt="Smile " height="20" width="22" /></li>

But this displays a broken image with the URL
http://www.domain.com/images/icons/smile%3C?php%20$random%20=%20rand(1,9);%20echo%20$ random;%20?%3E.gif

So it's clearly not parsing the php

However, I'm not good at this - can anyone fix my code?

Many many thanks

K

kersti
09-10-2010, 02:10 PM
Can noone help me here?

Lynne
09-10-2010, 02:23 PM
You cannot put php into a template. Templates are for html only. If you want to do some php, you need to do so in a plugin and then spit the result out into the template.

Have you done a search in the vb4 mods for random images? That may help you.