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 #175934 is a reply to message #175932] Wed, 09 November 2011 03:54 Go to previous messageGo to previous message
paris2venice is currently offline  paris2venice
Messages: 9
Registered: October 2011
Karma:
Junior Member
On Nov 8, 7:51 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> 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.
> jstuck...@attglobal.net
> ==================

I just want the captions in an array just like the filenames for the
images. I just don't know how to make the randomizer get the match
from each array.
[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: Tue Nov 26 14:01:34 GMT 2024

Total time taken to generate the page: 0.04351 seconds