Jump to content

Recommended Posts

I found random PHP slideshow script... but can't find where PHP can set up an array with n images and one and only one url for each rotatated image...  can PHP do this?  Or am I stuck with Java?  Or what?

 

automated script in html code for image rotate... url link also

 

array has images and url for link

 

automated pulls image and link from array

 

random and non-repeating.... once per page view.

 

Steer this ship.  PHP or Java?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/54504-random-image-rotator-php-or-java/
Share on other sites

You'd need an array containing all of the images (I think)

for example:

$images = array(0 => 'myimage.gif', 1 => 'myimage2.gif);

Then have a variable which is set at a random number between 0 and the amount in the variable.

$no = rand(0, count($images));

 

Then call the image like this:

<?php
echo '<img src="' . $images[$no] . '" border="0" width="100" height="100" alt="' . $images[$no] . '" />
?>

 

This was just made up very quickly so might be completly wrong, but it's what I'd try first...

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.