PDA

View Full Version : selectMenuGallery


Nicool
11-07-2003, 03:56 PM
Hye CGtalker,
I recently coded a php script that you can use to generate a simple image viewer diplaying the pictures (jpg and gif) from the folder where this script is located. It makes all for you automaticaly. How? simply copy this code and paste it in a text file calling "index.php".
That's better than a plain server folder sort! Use it, it's a gift !
An example here (http://ndhaussy.free.fr/temp/june2003/selectMenuGallery.php).





<table border=0>
<tr>
<td>
<select onChange="document.images['imageSelectMenu'].src=this.options[this.selectedIndex].value" >
<option value="" selected> Selection </option>
<?


// selectMenuGallery by Nicolas d'Haussy
// generate a navigation with select menu to display the picture from the folder where this script is located


// Lists the images of this directory and build the select menu.
$selectMenuItems;
$session=opendir(".");
while ($file=readdir($session)) {

if (is_file($file)) {

// Check if the file is an image
$extension = strtolower(substr(strrchr($file, "." ), 1 ));
if ($extension == "jpg" || $extension == "jpeg" || $extension == "gif") {

// Build the select menu
$selectMenuItems .= (" <option value=\"" . $file . "\">" . $file . "</option>\n");
}
}
}
closedir($session);
// Then display the dynamic menu items
echo ($selectMenuItems);
?>
</select>
</td>
</tr>
<tr>
<td>
<IMG NAME="imageSelectMenu" src="" BORDER="0">
</td>
</tr>
</table>

CGTalk Moderation
01-16-2006, 02:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.