Multiple folders and file

here it goes… i have folder A … in folder A, there are some folders… and in those folders, there are some files…

I have a code that list all folders in folder A and output them in a dropdown… Now what i need, is choose a folder in the dropdown and output the files in another dropdown… Is that possible?

I’ve been able to list the folders in folder A, but i have no clue what code to use to check what folder have been selected and output the corresponding files…

here is the code i have

<?php

/*#######################################################
*                                                        
*    THIS BLOCK OF CODE IS TO FETCH THE FIRST FOLDERS                                            
*    AND OUTPUT THEM IN OUR DROP DOWN MENU        
*
*********************************************************/

  $path = "./manga/";



  if ($dir_handle = @opendir($path)) 
  {
        
        while (($file = readdir($dir_handle)) !== false) 
        {
            
           if ($file != '.' && $file != '..')
            {   
              $output .= '<option value="'.$path.$file.'" name="'.$file.'">'.$file.'</option>';
            }
           
        }
        
        closedir($dir_handle);
    }
      else
    {
        echo "Unable to open $path";
    }
    
?>
<select id='choose' name='choose' onchange='selectManga()'>
<option>Choose a manga</option>
<?php echo $output;?>
</select>

Help me plz