I am playing around with a code example i found here about \'tree menu\' and wanted to make this question.
function tree($id)
{
$query = \"SELECT `name`,`id`
You need your tree
function to track the level, and then apply padding if the level is greater than 1.
function tree($id, $level=1) {
$query = "SELECT `name`,`id` from `table` WHERE `id_parrent` = '$id'";
$result = mysql_query($query);
if (mysql_num_rows($result) != 0) {
echo "";
while ($row = mysql_fetch_array($result)) {
if ($level == 1)
echo "- " . $row[name] . "
";
else
echo "- " . $row[name] . "
";
tree($row[id], $level + 1);
}
echo "
";
}
}