RE: [PHP] populate select box with contents of a file?
| From: | Wizaerd) | Date: | Thu, 08 Mar 2001 18:13:05 +0000 |
| Subject: | RE: [PHP] populate select box with contents of a file? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43052@lists.php.net to get a copy of this message | ||
<?php
$handle=opendir('.');
echo "<select name=image_url>";while (false!==($file = readdir($handle))) {
// new code here
$cExt = explode( ".", $file );
// and here
if ($file != "." && $file != ".." && ( strtolower( $cExt[1] ) == "jpg" ) {
echo "<option ";
echo "value=".$file.">";
echo $file;
echo "</option>\n\r";
}
}
echo "</select>";closedir($handle); ?> At 10:04 AM 3/8/01 -0800, Jerry Lake wrote:
Ok, I am using this modified code from the manual. It works great, but how do I modify it further to only show .jpg files ? <snip> <?php $handle=opendir('.');echo "<select name=image_url>";while (false!==($file = readdir($handle))) {if ($file != "." && $file != "..") { echo "<option "; echo "value=".$file.">"; echo $file; echo "</option>\n\r"; }}echo "</select>";closedir($handle); ?> </snipJerry Lake - jerryl@europa.comWeb Designer Europa Communications - http://www.europa.comPacifier Online - http://www.pacifier.com-----Original Message----- From: Sean R. Bright [mailto:elixer@erols.com] Sent: Wednesday, March 07, 2001 4:50 PM To: 'Jerry Lake'; 'Henrik Hansen'; 'php general' Subject: RE: [PHP] populate select box with contents of a file? Take a look at dir() and readdir(). Those along with echo() should help you out. Sean -----Original Message----- From: Jerry Lake [mailto:jerryl@europa.com] Sent: Wednesday, March 07, 2001 7:40 PM To: Henrik Hansen; php general Subject: [PHP] populate select box with contents of a file? I would like to be able to populate the options of a select box with the contents of my images directory online so I can select the image I want to go with the form I am filling out. what functions do I need to look into to figure this one out?Jerry Lake - jerryl@europa.comWeb Designer Europa Communications - http://www.europa.comPacifier Online - http://www.pacifier.com-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net