currently I am displaying data in Text format with recursive function like..
Food
Fruit
Red
Apple
Yellow
Banana
Meat
Beef
Pork
and I am using following code to display this text
function display_children($parent, $level) {
$result = mysql_query('SELECT * FROM category '.
'WHERE parant_id="'.$parent.'";');
while ($row = mysql_fetch_array($result)) {
echo str_repeat(' ',$level).$row['name']."\n";
display_children($row['id'], $level+1);
}
}
display_children(0,0);
But now I want to display the above text in <ul>
<li>
menu like
<ul>
<li>Food
<ul>
<li>Fruit
<ul>
<li>Red
<ul>
<li>Apple</li>
</ul>
</li>
<li>Yellow
<ul>
<li>Banana</li>
</ul>
</li>
</ul>
</li>
<li>Meat
<ul>
<li>Beef</li>
<li>Pork</li>
</ul>
</li>
</ul>
</li>
</ul>
All data is stored in table in following format
+----+-----------+--------+
| id | parant_id | name |
+----+-----------+--------+
| 1 | 0 | Food |
| 2 | 1 | Fruit |
| 3 | 1 | Meat |
| 4 | 2 | Red |
| 5 | 2 | Yellow |
| 6 | 4 | Apple |
| 7 | 5 | Banana |
| 8 | 3 | Beef |
| 9 | 3 | Pork |
+----+-----------+--------+
please help me to display whole data in <ul>
<li>
format
Thanks