 |

chassa2556
User
Jun 20, 2008, 2:44 PM
Post #1 of 2
(186 views)
Shortcut
|
|
Random picture display
|
Can't Post
|
|
Hi I would like to randomly display pictures on this index page. http://www.straloch.com/ I have an index page section with a gallery loaded. Is there a way that each time the page refreshes it calls in a new image? Many thanks in advance
|
|
|  |
 |

Dave
Staff
/ Moderator

Jun 21, 2008, 12:45 PM
Post #2 of 2
(168 views)
Shortcut
|
|
Re: [chassa2556] Random picture display
[In reply to]
|
Can't Post
|
|
Hi Charles. Did you figure this out already? When I reload the main page it seems like the image changes already? If not, you can display just one image by adding a <?php break; ?> tag at the end of the image foreach loop like this. (Note my variable is called $newsRecord, yours might be named something else).
<?php foreach ($newsRecord['uploads'] as $upload): ?> ... display image here ... <?php break; ?> <?php endforeach ?> Break means "break out of the loop" and only show one. Next, you can shuffle the order of the uploads so the first one displayed will always be random. Just add this tag _before_ the foreach tag:
<?php shuffle($newsRecord['uploads']); ?> <?php foreach ($newsRecord['uploads'] as $upload): ?> ... Hope that helps! Let me know if you have any more questions about that. Dave Edis - Senior Developer interactivetools.com
|
|
|  |
|