+ 我來回答
回答最高可+2積分
我敢打賭,他只是照著念稿子,他自都不懂遞歸的真正的精髓,或者說原理吧,連歸都不知道,我實(shí)在喊不出老師兩個(gè)字
2018-01-11
老師辛苦了,代碼全看懂了,邏輯有點(diǎn)不行,哈哈,還是不錯(cuò)的
2017-11-25
function getCatePath($id){
$sql = "select * from imooc where id = ?";
$stmt = $GLOBALS['db2']->prepare($sql);
$stmt->execute(array($id));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if($data!=null){
getCatePath($data['pid']);
echo "<a href='#'>".$data['catename'].">"."</a>";
}
}
getCatePath(10);
$sql = "select * from imooc where id = ?";
$stmt = $GLOBALS['db2']->prepare($sql);
$stmt->execute(array($id));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if($data!=null){
getCatePath($data['pid']);
echo "<a href='#'>".$data['catename'].">"."</a>";
}
}
getCatePath(10);
2017-11-24
$sql = "select * from imooc where pid = ?";
$stmt = $GLOBALS['db2']->prepare($sql);
$stmt->execute(array($pid));
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
for ($i = 0; $i < count($row); $i ++) {
$data[] = $row[$i];
getList($row[$i]['id'],$data);
}
return $data;
$stmt = $GLOBALS['db2']->prepare($sql);
$stmt->execute(array($pid));
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
for ($i = 0; $i < count($row); $i ++) {
$data[] = $row[$i];
getList($row[$i]['id'],$data);
}
return $data;
2017-11-24