S
shiva0101 m
Guest
Hi,
I have to display a tree from database. I searched and found the below code. It is working very well. I am displaying the contents by using templates. But, the below code echo's the contents. Can someone tell me how to store the contents in a variable and display the contents.
I tried by i could not display all the contents.
function tree_set($index)
{
$q=mysql_query("select * from categories where parent_id=$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_set($arr['id']);
echo '</li>';
}
echo '</ul>';
}
tree_set(0);
Thanks
I have to display a tree from database. I searched and found the below code. It is working very well. I am displaying the contents by using templates. But, the below code echo's the contents. Can someone tell me how to store the contents in a variable and display the contents.
I tried by i could not display all the contents.
function tree_set($index)
{
$q=mysql_query("select * from categories where parent_id=$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_set($arr['id']);
echo '</li>';
}
echo '</ul>';
}
tree_set(0);
Thanks