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