View Single Post
Old 12-10-2008, 10:49 AM   #3 (permalink)
oscargodson
The Wanderer
 
Join Date: Jun 2008
Posts: 19
Thanks: 0
oscargodson is on a distinguished road
Default

I actually got it thanks to a guy over at tizag.com. He wrote me a small function that worked right out of the box. Just in case anyone else needs to make a site tree of some sort using a ul (could be an ol of course):

PHP Code:

function tree_view($index)
{
    
$q=mysql_query("SELECT * FROM table_name WHERE parent=$index");
    if(!
mysql_num_rows($q))
        return;
    echo 
'<ul>';
    while(
$arr=mysql_fetch_assoc($q))
    {
        echo 
'<li>';
        echo 
$arr['name'];//you can add another output there
        
tree_view($arr['id']);
        echo 
'</li>';
    }
    echo 
'</ul>';

then simply call it with:
PHP Code:
tree_set(0); 
Worked like a charm!
oscargodson is offline  
Reply With Quote