亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP ?? ?? ???? ?? ??(1?)

?? ??

遞歸.png

???? ?? ?? ?? ??

<?php
include ("conn.php");
function getList($pid=0,&$result=array(),$space=0){
    $space=$space+2;
    $sql="SELECT*FROM deepcate WHERE pid = $pid";
    $res = mysql_query($sql);
    while ($row = mysql_fetch_assoc($res)){
        $row['catename']=str_repeat('&nbsp;',$space).'|--|'.$row['catename'];
        $result[]=$row;
        getList($row['id'],$result,$space);
    }
    return $result;
}
$rs=getList();
function displayCate($pid=0,$selected=1){
    $rs=getList($pid);
    $str='';
    $str.="<select name='cate'>";
    foreach ($rs as $key=>$val){
        $selectedstr='';
        if ($val['id'] == $selected){
            $selectedstr="selected";
        }
        $str.="<option{$selectedstr}>{$val['catename']}</option>";
    }
    return $str.='</select>';
}
echo displayCate(0,2);
?>

??? ???? ???? ??? ?????.

?? ??:

<?php
include ("conn.php");
function getList($pid=0,&$result=array(),$space=0){
   $space=$space+2;
   $sql="SELECT*FROM deepcate WHERE pid = $pid";
   $res = mysql_query($sql);
   while ($row = mysql_fetch_assoc($res)){
       $row['catename']=str_repeat('&nbsp;',$space).'|--|'.$row['catename'];
       $result[]=$row;
       getList($row['id'],$result,$space);
   }
   return $result;
}
$rs=getList();
?>
function getList($pid=0){
}
?>

?? pid? ?? ??? ID? ?? 0?? ???? ??? ?????.

$sql="SELECT*FROM deepcate WHERE pid = $pid";

SQL ?? ???? PID ?? ??? ?? ???? ?????.

$res = mysql_query($sql);
//執(zhí)行sql語句
    $result=array();
   while ($row = mysql_fetch_assoc($res)){
       $result[]=$row;
      }
   return $result;

??? ??? ?? ??? ?????.

??? ??? ??? ???? ?????. ?? ???? ??? ? getList($row['id'])? ???? ???.

?? ???? ID? ?? ???? ID? ???? ???. $row['id'])? ???? ???

?? ???

<?php
function getList($pid=0){
$sql="SELECT*FROM deepcate WHERE pid = $pid";
$res = mysql_query($sql);
  $result=array();
   while ($row = mysql_fetch_assoc($res)){       $result[]=$row;      }   return $result;
}
?>

?? ???? ??? ???? ??? ?? ???? ???? ??? ?????

<?php
include ("conn.php");
function getList($pid=0,&$result=array()){
   $sql="SELECT*FROM deepcate WHERE pid = $pid";
   $res = mysql_query($sql);
   while ($row = mysql_fetch_assoc($res)){
       $result[]=$row;
       getList($row['id'],$result);
   }
   return $result;
}
?>

?? ?? ???? ???? ???????

<?php
include ("conn.php");
function getList($pid=0,&$result=array(),$space=0){
   $space=$space+2;
   $sql="SELECT*FROM deepcate WHERE pid = $pid";
   $res = mysql_query($sql);
   while ($row = mysql_fetch_assoc($res)){
       $row['catename']=str_repeat('&nbsp;',$space).'|--|'.$row['catename'];
       $result[]=$row;
       getList($row['id'],$result,$space);
   }
   return $result;
}
$rs=getList();
print_r($rs);
?>

???? ??????.


? ?? ??

  1. ?? ?? ??? ??? ??? ??? ???? ?? ??? ?? ???? ???? ????.

  2. ?? ??? ? ?? ???.

???? ??
||
<?php include ("conn.php"); function getList($pid=0,&$result=array(),$space=0){ $space=$space+2; $sql="SELECT*FROM deepcate WHERE pid = $pid"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)){ $row['catename']=str_repeat(' ',$space).'|--|'.$row['catename']; $result[]=$row; getList($row['id'],$result,$space); } return $result; } $rs=getList(); print_r($rs); ?>