Get Subfolders

Get all subfolders in a MySQL table using PHP.

PHP Programming.

Date Created:Friday March 09th, 2007 10:13 PM
Date Modified:Saturday August 02nd, 2008 03:55 PM

function get_subfolders $db$parent_id$get_info false )
    $fields = ( $get_info ) ? '*' 'folder_id, title';
    $query  'SELECT ' .$fields' FROM folders WHERE parent_id = '$parent_id;
    $sth    mysql_query($db$query);

    while ( $row mysql_fetch_row($sthMYSQL_ASSOC) )
        $folders[array_shift($row)] = $row;

    return $folders;

Download: subfolders.php 391 B

Please login or Click Here to register for downloads
Creative Commons License
Get Subfolders by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at
Permissions beyond the scope of this license may be available at