mrheff Posted March 1, 2007 Share Posted March 1, 2007 okey poke her goes..... i been scrching my head all day after succesfully knocking up a menu/catergory creation system which auto displays catergories created in to the menu once made. my lil problem is trying to create a drop down which allows me to send things to specific catergories which are actually directories. this is what ive foun d from zend but i cant get it to go.... dropit.php <? function dir2box($path, $name, $default="") { $result="<select name="$name" size=1>n"; $handle=opendir("$path"); while ($file = readdir($handle)) { if ($file == $default) {$selected="selected";} else {$selected="";} if ($file != "." and $file !="..") {$result.="<option value="$file" $selected>$file</option>n";} } closedir($handle); $result.="</select>n"; return $result; } ?> and heres the front side... <? require("dropin.php"); $default=""; $path="/results"; ?> <form> <p> Files : <? echo dir2box($path, "directory", $default); ?> <p> </form> and justr to clarify, its the folders within /results/ i would like to view in the menu Also does anyone know how i get this menu ive made: <?php $dirname = "results"; $dh = opendir($dirname) or die("couldn't open directory"); while (!(($file = readdir($dh)) === false ) ) { if (is_dir("$dirname/$file")) { echo "<a href=results/$file/gallery.php>$file</a> <br/>"; } } echo 'these are the current directories'; closedir($dh); ?> ....to stop showing the " . " and the " .. " from appearing?????????? Thanks if you have any ideas fellas, your allways a great hand so far. Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/ Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 a little modification will stop showing . and .. use this while (!(($file = readdir($dh)) === false ) ) { if (is_dir("$dirname/$file") && $file!="." && $file !="..") { echo "<a href=results/$file/gallery.php>$file[/url] "; } } Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/#findComment-196944 Share on other sites More sharing options...
mrheff Posted March 1, 2007 Author Share Posted March 1, 2007 aaaahhhh thank you... i was playing with this, if ($file=='.' || $file=='..') but i couldnt figure the place ment but i think iseee now, thanks mate it didnt work straight away for me, but wit a lil tweek it ended up like this...... <?php $dirname = "results"; $dh = opendir($dirname) or die("couldn't open directory"); while (!(($file = readdir($dh)) === false ) ) { if (is_dir("$dirname/$file") && $file!="." && $file !="..") echo "<a href=results/$file/gallery.php>$file</a> <br/>"; } echo 'these are the current directories'; closedir($dh); ?> Thanks again. Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/#findComment-196960 Share on other sites More sharing options...
mrheff Posted March 1, 2007 Author Share Posted March 1, 2007 So how do i now populate a drop down with that as an option? do i echo a form with with $file as the value or the name of the input? the purpose of this is willl be to send the directory as a variable when placing files in the relative direcotries. whoop whoop............. Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/#findComment-196997 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 yup you can do it that way Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/#findComment-197003 Share on other sites More sharing options...
mrheff Posted March 1, 2007 Author Share Posted March 1, 2007 Mhgauhauhgauhgauhaguhaguhag thank you mate heres how i got it now to show me the drop down. <SELECT NAME=directory> <?php $dirname = "results"; $dh = opendir($dirname) or die("couldn't open directory"); while (!(($file = readdir($dh)) === false ) ) { if (is_dir("$dirname/$file") && $file!="." && $file !="..") echo " <OPTION VALUE=$file> $file " ; } closedir($dh); ?> </SELECT> Link to comment https://forums.phpfreaks.com/topic/40699-ohw-it-never-stops-problems-creating-directory-drop-down/#findComment-197023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.