Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

[solved]select dir problam cheers.

Recommended Posts

i need to get the select statement to show all the directorys in the select output please help cheers.

know if i put the echo $info within the loop then i get 6 sets of selects so i am trying to output one select with all dir how?



[code]
<?php

$dirpath = "files/";

$dlist = opendir($dirpath);

while ($read = readdir($dlist)) {

$info="<select name='dir'><option value='$read'>$read</option></select>";

}
closedir($dlist);

echo $info;
?>
[/code]

Share this post


Link to post
Share on other sites
[code]
<?php

$dirpath = "files/";

$dlist = opendir($dirpath);

$info = "<select name='dir'>";
while ($read = readdir($dlist)) {

$info.="<option value='$read'>$read</option>";

}
closedir($dlist);
$info.="</select>";
echo $info;
?>
[/code]

Share this post


Link to post
Share on other sites
so what was it then the way i set the select up then can you exsplain what was wrong cheers m8.

the code is only for me to understand as a test code to see how it works as meny ask the same question so i was intrested to get it going thank you for the ansaw m8.

ok i get it if you take the <select name=' '> out of the while loop then it only sees it as one select statement but if within the while loop then loops all.

solved cheers.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.