MLM二叉树视图之字形?

时间:2014-04-16 17:16:37

标签: php mysql mysqli tree binary-tree

我希望逐级显示二叉树...但我无法显示

    <?php

     if($_GET)


    {
$name = $_GET['sname'];
function showdownline($sname)
    {

$con = $_SESSION['con'];
$query = "SELECT * FROM clients WHERE name = '$sname'";
$result = mysqli_query($con,$query);
if(mysqli_num_rows($result)==0)
    return(0);
else{
    while($row = mysqli_fetch_array($result))
    {

        echo $left = $row['left_client']." ";
        echo $right = $row['right_client']." ";

        }
showdownline($left);
showdownline($right);
    }
}
showdownline($name);
    }

&GT;

它向我展示了整条左腿然后向右......帮助我 我认为它首先被称为广度 预期产出 例如,如果表中的数据是

ID | name | left_client | right_client|
 1 | a | b | c | 
2 | b | d | e | 
3 | c | f | g |
 4 | f | h | i |
 5 | g | j | k |

如果我们想获得成员a的树然后输出那么输出应该是

a , b , c , d, e ,f ,g, h, i, j, k

0 个答案:

没有答案