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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.