Closed Thread Icon

Topic awaiting preservation: Random Img and Text (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12837" title="Pages that link to Topic awaiting preservation: Random Img and Text (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Random Img and Text <span class="small">(Page 1 of 1)</span>\

 
darknosis
Bipolar (III) Inmate

From: Lahore, Pakistan
Insane since: Mar 2003

posted posted 07-28-2003 09:25

does anyone know a script which randomly selects an img and also displays text according to the picture. like for example the script randomly selects a picture of a flower and also according to the picture displays text. i know how to make the random img script its the text thingy that confusing me

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-28-2003 12:57

darknosis: The simplest thing would be to have an array with the image and the text in it. I have the code here to do it in PHP but you haven't specified what language you want this in.

___________________
Emps

FAQs: Emperor

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-28-2003 13:19

Something like:

code:
$images = array(
'House' =>
array('url' => 'house.jpg',
'description' => 'A picture of my house'),
'Hat' =>
array('url' => 'hat3.jpg',
'description' => 'A picture of my hat')
);

srand ((float)microtime()*1000000);
shuffle ($images);
// for some reason once doesn't seem to do the job so we go again
srand ((float)microtime()*1000000);
shuffle ($images);

$random_image_link = $images[1][url];
$random_image_description = $images[1][description];

echo "<img src=\"/image_folder/" . $random_image_link . "\" />";
echo "<p>" . $random_image_description . "</p>";



There are probably problems in there but it is a start.


___________________
Emps

FAQs: Emperor

darknosis
Bipolar (III) Inmate

From: Lahore, Pakistan
Insane since: Mar 2003

posted posted 07-28-2003 14:34

any language will do, the thing is each img has several lines of text and a few links

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-28-2003 14:49

darknosis: Any? Well that will do then

There is nothing to stop you having HTML in the array or you could add other elements into your array for the extra information.

___________________
Emps

FAQs: Emperor

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 07-28-2003 15:21

Check out this one:
http://www.ozoneasylum.com/Forum12/HTML/001342.html

This was back when we helped master suho do something similar...that's if you want the text as part of the image...if not the esteemed Emperor's example is the way to go.

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 07-28-2003 15:25

hell, you could even keep this stuff as seperate files and read them into the page..

e.g.

/house.jpg
/house.caption
/hat3.jpg
/hat3.caption

excetera....


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 07-28-2003 15:55

Yeah...or you could do it that way

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 07-28-2003 19:47

That's how I do it for my wife's artwork .. I have 3 directories .. thumbs, images and descriptions, each containing files with the same names, (but different extensions) ... then I use PHP to read the contents of the thumbs directory and store the root-filenames in an array. From there on it's pretty simple to display them and when someone clicks on a thumbnail, to display the equivalent image and text in the boxes on the page ...


Bug-free software only exisits in two places
A programmer's mind and a salesman's lips

[This message has been edited by trib (edited 07-28-2003).]

« BackwardsOnwards »

Show Forum Drop Down Menu