Jump to content

ohw it never stops, problems creating Directory drop-down


mrheff

Recommended Posts

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.

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] 
";
   }

}


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.

 

 

 

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.............

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>

Archived

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

×
×
  • Create New...

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.