Hello The code bellow checks foldernames and lists them as you can se bellow. the problem i have is that they dont line up. First the table puts out these 3 collumns "Cars, released by, Added on" and under those "<? echo get_folders_list("mech/cars/"); ?>" is supposed to show all the folders in /mech/cars/ and put them in line under the 3 collumns the table pt out however. the output from <? echo get_folders_list("mech/cars/"); ?>" currently put those folder bellow everyting, for example if i have 2 folders in /mech/cars/ (lamborghini and open is there) the output becomes car realesed by Added on AnCo 2009-10-30 - 04:02 AnCo 2009-10-30 - 04:02 lamborghini opel when i want it to be car realesed by Added on lamborghini AnCo 2009-10-30 - 04:02 Opel AnCo 2009-10-30 - 04:02 why is this? I hope some one can help me fix the problem :/ <?php function get_folders_list($path_to_folder_of_folders){ $dir_handle = @opendir($path_to_folder_of_folders) or die("Unable to open $path_to_folder_of_folders"); $folders = ""; while ($directory = readdir($dir_handle)) { if($directory != "." && $directory != "..") if (is_dir($path_to_folder_of_folders.$directory)){ echo '<tr>'; $folders .= '<td> <a href="http://mydoimain.com/'.$directory.'">'.$directory."</a><td><br><br>"; echo '<td><a href="lamb" title="lab">lamb</a></td>'; echo '<td>2009-10-30 - 04:02</td>'; echo '</tr>'; } } closedir($dir_handle); return $folders; } ?> <table class="records"> <tr class="header"> <td>car</td> <td class="release_column">realesed by</td> <td class="added_column">Added on</td> </tr> <? echo get_folders_list("mech/cars/"); ?> </table> PHP:
i dont know why you are doing this: $folders .= '<td> <a href="http://mydoimain.com/'.$directory.'">'.$directory."</a><td><br><br>"; Code (markup): just do: echo '<td> <a href="http://mydoimain.com/'.$directory.'">'.$directory."</a></td>"; Code (markup): also, you don't need to return anything on that function. So: <?php function get_folders_list($path_to_folder_of_folders){ $dir_handle = @opendir($path_to_folder_of_folders) or die("Unable to open $path_to_folder_of_folders"); $folders = ""; while ($directory = readdir($dir_handle)) { if($directory != "." && $directory != "..") if (is_dir($path_to_folder_of_folders.$directory)){ echo '<tr>'; echo '<td> <a href="http://mydoimain.com/'.$directory.'">'.$directory."</a></td>"; echo '<td><a href="lamb" title="lab">lamb</a></td>'; echo '<td>2009-10-30 - 04:02</td>'; echo '</tr>'; } } closedir($dir_handle); return; } ?> <table class="records"> <tr class="header"> <td>car</td> <td class="release_column">realesed by</td> <td class="added_column">Added on</td> </tr> <? get_folders_list("mech/cars/"); ?> </table> Code (markup):
also, dont forget that you are at one point using the <?php and at another point only the <? - which some webhotels dont like... Good piece of code otherwise