Page 1 of 1

Using glob to display images

Posted: Mon Sep 11, 2006 11:48 pm
by akimm
Guys, I got this code to display textual forms of the images, but does anyone know how to make the $value set within an <img src=""> so that it prints value as an image rather than text?

Code: Select all

<?php 

$files = glob("smile/*.gif"); 
##Display $files  

foreach ($files as $key => $value) 
{ 
echo "<option value="'  .  "<img src=$value>'" . ">" . "<img src=$value>" . "</option>";    
}
?>
</select>

Posted: Mon Sep 11, 2006 11:53 pm
by s.dot
You can't display images inside of a select box.

Ah, ok.

Posted: Tue Sep 12, 2006 12:12 am
by akimm
and its 90 some images, using radios would probably look insane.

Posted: Tue Sep 12, 2006 5:24 am
by bokehman
Why not stick with the dropdown and when one of the filenames is selected display a thumbnail of the image using Javascript.

hmm

Posted: Tue Sep 12, 2006 6:43 am
by akimm
Thats a wonderful idea, I am not very versed in Javascript, so I wouldn't know how to achieve that aspect of the code, but iwill look into it, after my BIO lab lol.

Thanks for the suggestion, very good of you.

Posted: Tue Sep 12, 2006 6:45 am
by onion2k
scottayy wrote:You can't display images inside of a select box.
Actually you can if you use a background set with CSS .. not sure if it's completely cross-browser compatible though.

Posted: Tue Sep 12, 2006 6:51 am
by bokehman
onion2k wrote:
scottayy wrote:You can't display images inside of a select box.
Actually you can if you use a background set with CSS .. not sure if it's completely cross-browser compatible though.
That only works in Gecko browsers so it's a no no with IE and Opera.