亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

1 回答

<?php


function getList($pid=0,&$res=array(),$spac=0){

$spac=$spac+4;

$link=mysqli_connect('localhost','root','root') or die('沒有鏈接到服務器');

? ? mysqli_select_db($link,'deepcate') or die("沒有鏈接到表");

$sql="select * from cate where pid={$pid}";

$rows=mysqli_query($link, $sql);

if($rows){

? ? ?while($row=mysqli_fetch_assoc($rows)){

? ? ? $row['catename']=str_repeat('&nbsp;',$spac).'|--'.$row['catename'];?

? ? ? $res[]=$row;

getList($row['id'],$res,$spac);

? ? }

return $res;

}

}


function showList($pid=0,$select){

$result=getList($pid);

echo "<select name='cate'>";

foreach ($result as $key => $value) {

$selecstr='';

if($value['id']==$select){

$selectstr='selected';

}

?echo "<option ?{$selectstr} >{$value['catename']}</option>";

}

}



function getCatePath($id,&$res=array(),$spac=0){

$spac=1;

$link=mysqli_connect('localhost','root','root') or die('沒有鏈接到服務器');

? ? mysqli_select_db($link,'deepcate') or die("沒有鏈接到表");

$sql="select * from cate where id={$id}";

$rows= mysqli_query($link, $sql);

if($rows){

while($row=mysqli_fetch_assoc($rows)){

$row['catename']=$row['catename'].str_repeat('>',$spac);

$res[]=$row;

getCatePath($row['pid'],$res,$spac);

}

krsort($res);

return $res;

}

}


function showCatePath($id){

$res=getCatePath($id);

foreach ($res as $key => $value) {

echo "<a href='cate.php?cid={$value['id']}'>{$value['catename']}</a>";

}

}

showCatePath(10);

?>

純自寫<--!>

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

有源碼下載嗎

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號