The content of this article is about how to implement full-path unlimited classification navigation (code) in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
<?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=');
The above is the detailed content of How to implement full-path unlimited category navigation in PHP (code). For more information, please follow other related articles on the PHP Chinese website!