danscreations Posted August 14, 2008 Share Posted August 14, 2008 Not sure what's going on with the coding I wrote but I have a simple part of a script that looks a specified folder and is suppost to get all the subfolders, sort them, and display them (in the form of a dropdown menu). For some reason some folders aren't showing up. My inital thought was the nameing but I have other cases where the missing subfolder from the list has a completely different starting letter (for sorting). Anyone have any idea whats wrong? Example of actual contents: C3 C4 C5 C6 C6 Z06 Example of what gets displayed in the dropdown (C6 is missing?!?!) C3 C4 C5 C6 Z06 $model_folder = 'gallery/'.$make.'/'; $open_model = opendir($model_folder); echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="gallery_model_select">'; echo '<select name="model" onchange="document.gallery_model_select.submit()"'; if(empty($make)){echo' disabled';} echo '>'; echo '<option value="">Select Model</option>'; while($display_model = readdir($open_model)){ if(is_dir($display_model)){ } else { $model_files[] = $display_model; } } sort ($model_files); foreach ($model_files as $model_data){ echo '<option value="'; echo $model_data; echo '" '; if ($model_data == $model){ echo 'selected'; } echo '>'; echo $model_data; echo '</option>'; } closedir($model_folder); Quote Link to comment Share on other sites More sharing options...
taith Posted August 14, 2008 Share Posted August 14, 2008 oh the wonders of glob()... $files=glob("gallery/$make/C*"); will make an array of all files in the gallery/$make directory that start with a C use that for your loops Quote Link to comment Share on other sites More sharing options...
danscreations Posted August 14, 2008 Author Share Posted August 14, 2008 oh the wonders of glob()... $files=glob("gallery/$make/C*"); will make an array of all files in the gallery/$make directory that start with a C use that for your loops Cool...only issue is it's not only folders with the same starting letter. I have another folder and here is the outcome. Example of actual contents: FIRST GEN FBODY Example of what gets displayed in the dropdown (FBODY is missing?!?!) FIRST GEN It seems consistant that I have issues in folders containing subfolders with the same starting letter but would like to make the coding globle as not all folders have sub folders that start with "C" or "F". Any ideas? Quote Link to comment Share on other sites More sharing options...
danscreations Posted August 18, 2008 Author Share Posted August 18, 2008 Anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.