Jump to content

If than statement (based of a subfolder)


danscreations

Recommended Posts

I'm writing a simple gallery script which generates the navigation based off of the folder structure (to some degree). There are a series of folders and sub folders which generate each dropdown. In the dropdown for the chassis_folder there will either be several sub folders of chassis or there will be a single "ALL" folder. Not sure how to add/re-arrange my coding so that the script opens the $chassic_folder looks for the "ALL" folder and if it exsist set $chassis to equal "ALL" and if it doesn't exsist display each $display_chassis.

 

Live script: http://www.ccwheel.com/dan/gallery.php

 

$chassis_folder = 'gallery/'.$make.'/'.$model.'/';

$open_chassis = opendir($chassis_folder);

if(empty($make)){

} else {

if(empty($model)){

} else {

echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="gallery_chassis_select">';

echo '<select name="chassis" onchange="document.gallery_chassis_select.submit()">';

echo '<option>Select Chassis</option>';

while($display_chassis = readdir($open_chassis)){

  if(is_dir($display_chassis)){

  } else {

$chassis_files[] = $display_chassis;

  }

}

 

sort ($chassis_files);

foreach ($chassis_files as $chassis_data){

echo '<option value="';

echo $chassis_data;

echo '" ';

if ($chassis_data == $chassis){

echo 'selected';

}

echo '>';

echo $chassis_data;

echo '</option>';

}

 

echo '</select>';

echo '<input type="hidden" name="make" value="';

echo $make;

echo '">';

echo '<input type="hidden" name="model" value="';

echo $model;

echo '">';

echo '</form>';

echo '</td>';

echo '<td>';

}

}

closedir($chassis_folder);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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