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 #175936 is a reply to message #175935] Wed, 09 November 2011 07:51 Go to previous message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma:
Member
paris2venice wrote:
> On Nov 8, 7:34 pm, paris2venice <paris2ven...@gmail.com> 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.
>
> I neglected to mention that I am not using MySQL or any other database
> so I can't use that (at least not right now). Thanks.

Put it all on one line. Put that in a file. Each line will be an image
with the caption. Then use whatever randomizer you want to include a
line.

houghi
--
> This is written under the influence of tv channel
> Some Channel (as there was nothing else on).
[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: Sat Nov 23 22:37:58 GMT 2024

Total time taken to generate the page: 0.03839 seconds