function get_dtypelist($dtype_id,$fun_count){
$result=mysql_query("SELECT * FROM category where dtype_up ='$dtype_id'");
while ($row=mysql_fetch_array($result))
{
echo "<option value='".$row['dtype_id']."'>";
for($j=0;$j<$fun_count;$j++){
echo "&nbsp;";
}
echo "|→".$row['dtype_name']."</option>";
if(get_dtypecount($row['dtype_id'])>0)
{
$fu_count=$fun_count+1;
get_dtypelist($row['dtype_id'],$fu_count);
}
}
}参考一下

解决方案 »

  1.   

    哦,忘记了另外一个function get_typecount($type_id){
    $query_count=mysql_query("SELECT count(type_id) as c_total FROM category where type_up='$type_id'");
    $arr_count=mysql_fetch_array($query_count);
    $total=$arr_count[c_total];
    return $total;
    }
      

  2.   

    晕,上面那个代码有点问题,改成这个function get_dtypecount($dtype_id){
    $query_dcount=mysql_query("SELECT count(dtype_id) as dc_total FROM category where dtype_up='$dtype_id'");
    $arr_dcount=mysql_fetch_array($query_dcount);
    $dtotal=$arr_dcount[dc_total];
    return $dtotal;
    }