PHP全路徑無限分類導航LINK代碼實現
阿新 • • 發佈:2018-09-19
pan select lin ray col 無限 code class ids
<?php /** * @param php全路徑無限分類 */ include(‘db.inc.php‘); function getPathCate($cateid){ $sql = "select * ,concat(path,‘,‘,id) fullpath from likecate where id = $cateid"; $res = mysql_query($sql); $row = mysql_fetch_assoc($res); $ids = $row[‘fullpath‘]; $sql = "select * from likecate where id in ($ids) orders by id asc"; $res = mysql_query($sql); $result = array(); while ($row = mysql_fetch_assoc($res)) { $result[] = $row; } return $result; } function displayPath($cateid,$link=‘cate.php?cid=‘){ $res = getPathCate($cateid); $str = ‘‘; foreach ($res as $key => $value) { $str .= "<a href =‘{$link}{$value[‘id‘]}‘>{$value[‘catename‘]}</a>"; } } echo displayPath(4,‘cate.php?p=1&cid=‘);
PHP全路徑無限分類導航LINK代碼實現