Jump to content

Adding a random image generator in exisiting php code


Jurik

Recommended Posts

Hi guys,

        I've been asked to add a radom image generator to a site that is using Mambo to create it's web-site in. At the moment the image that is needed to become a random image is using the following code

[code]
<img src="<?php echo $mosConfig_live_site; ?>/templates/waterandstone_green/images/img_header.jpg" alt="header image" />
[/code]

Now I have tried to add some scripts I have found on the net to make this image randomly selected but I just cant seem to get it to work, can anyone help me out?
well you how much other images are there. i am guessing you are changing img_header.jpg?
well just have a couple of those with a number on the end. then use the rand.

[code=php:0]
<img src="<?php echo $mosConfig_live_site; ?>/templates/waterandstone_green/images/img_header<?php echo rand(1, 4); ?>.jpg" alt="header image" />[/code]

remember to change the 4 to however many images there are.
[quote author=ProjectFear link=topic=118168.msg482584#msg482584 date=1165838603]
well you how much other images are there. i am guessing you are changing img_header.jpg?
well just have a couple of those with a number on the end. then use the rand.

[code=php:0]
<img src="<?php echo $mosConfig_live_site; ?>/templates/waterandstone_green/images/img_header<?php echo rand(1, 4); ?>.jpg" alt="header image" />[/code]

remember to change the 4 to however many images there are.
[/quote]

Thats works a treat, thanks alot

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.