Reply
randomly display page
Old 05-20-2008, 10:53 AM randomly display page
rezzy's Avatar
Skilled Talker

Posts: 90
Location: in the interwebz
Currently, I have a list of images.

Image1
Image2
Image3

I want the order to be random for displaying the images. I had considered using a randomly selected case statement, but I think that would be a bad idea. So then I thought using a random interger and then make an if statement to count and display the other images.
__________________
Resnodesigns
Visit my PHP Scripts blog and leave comments!
rezzy is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-20-2008, 11:49 AM Re: randomly display page
Average Talker

Posts: 28
Are the images in an array? Do they all share a common naming syntax? Are they coming from a database? Are all of the images in the same folder, and does that folder ONLY contain these images? Do we care about true randomness (the same image may show more than once)?

There are many ways to tackle this problem. We'll need to know more about this circumstance.
Cory Dee is offline
Reply With Quote
View Public Profile
 
Old 05-20-2008, 03:02 PM Re: randomly display page
wayfarer07's Avatar
$frontend->developer

Posts: 1,016
Name: Abel Mohler
Location: Asheville, North Carolina USA
If you don't have a defined approach, I definitely recommend placing the image file paths into an array and using the rand() function to select them based on location in the array. Place the images into a new array in a random order, then output them by looping through the array with a foreach statement. I'll leave you to work out the minor details.
__________________
Go FREELANCE <=|If a donkey eats a melon, it is still a donkey... |=> Hire Me
wayfarer07 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to randomly display page
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12434 seconds with 12 queries