12-10-2008, 10:49 AM
|
#3 (permalink)
|
|
The Wanderer
Join Date: Jun 2008
Posts: 19
Thanks: 0
|
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:
Worked like a charm!
|
|
|
|