Using glob to display images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Using glob to display images

Post 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>
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

You can't display images inside of a select box.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Ah, ok.

Post by akimm »

and its 90 some images, using radios would probably look insane.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Why not stick with the dropdown and when one of the filenames is selected display a thumbnail of the image using Javascript.
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

hmm

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post 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.
Post Reply