Tema: Formularios
Créditos: Zsamer
Pregunta: ¿Cómo puedo mostrar en un formulario select valores de un directorio?
Respuesta:
Código PHP:
<?php
$content .= "</br>";
$content .= "<center>";
$content .= "<form action=\"skins.php\" method=\"post\">";
$content .= "<select name=\"skins\">";
$handle=opendir('skins');
while ($file = readdir($handle)) {
if ( (!ereg("[.]",$file)) ) {
$themelist .= "$file ";
}
}
closedir($handle);
$themelist = explode(" ", $themelist);
sort($themelist);
for ($i=0; $i < sizeof($themelist); $i++) {
if($themelist[$i]!="") {
$content .= "<option value=\"$themelist[$i]\" ";
if((($userinfo[theme]=="") && ($themelist[$i]=="$Default_Theme")) || ($userinfo[theme]==$themelist[$i])) $content .= "selected";
$content .= ">$themelist[$i]\n";
}}
$content .= "</option>";
$content .= "</select>";
$content .= "</br>";
$content .= "</br>";
$content .= "<input type=\"submit\" value=\"Cambiar\">";
$content .= "</form>";
echo $content
?>