FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » displaying random images with an appropriate caption
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: displaying random images with an appropriate caption [message #175932 is a reply to message #175931] Wed, 09 November 2011 03:51 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 11/8/2011 10:34 PM, paris2venice wrote:
> Is there any way to write something that will choose not just a random
> image but the random image and its caption as a pair?
>
> This is my code for my random images as it exists now but,
> unfortunately, it doesn't work very well if I don't have a caption
> with the photo (even if just to credit the photographer):
>
>
> <div style="float:right; width:363px;
> margin: 1.0em 2.75em 1.0em 1.0em; padding: 0.25em;
> text-align:center; background-color: #fff">
> <?php
> $dir="/library/images/slideshow";
> $images = array("$dir/farm-640x480.gif" ,
> "$dir/ranch-640x480.gif" ,
> "$dir/plantation-640x480.gif");
> $format='<img src="%s"
> class="rounded-corners"
> style="width:360px;height:270px" />';
> printf("$format", $images[array_rand($images)]);
> echo "\n";
> ?>
> </div>
>
> Thanks for any help and/or suggestions.

A better question is - how do you want to relate the caption to its
picture? Once you've decided how you want to relate them on your
server, displaying the related caption is easy.

It could be a database... file name similarity... different
directories... about anything you want.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php development environment in windows problems
Next Topic: Images retrives
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 19:54:17 GMT 2024

Total time taken to generate the page: 0.04263 seconds