How to implement full-path unlimited category navigation in PHP (code)

不言
Release: 2023-04-04 09:08:01
forward
3213 people have browsed it

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(&#39;db.inc.php&#39;);
function getPathCate($cateid){
    $sql = "select * ,concat(path,&#39;,&#39;,id) fullpath from likecate where id = $cateid";
    $res = mysql_query($sql);
    $row = mysql_fetch_assoc($res);
    $ids = $row[&#39;fullpath&#39;];
    $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=&#39;cate.php?cid=&#39;){
    $res = getPathCate($cateid);
    $str = &#39;&#39;;
    foreach ($res as $key => $value) {
        $str .= "<a href =&#39;{$link}{$value[&#39;id&#39;]}&#39;>{$value[&#39;catename&#39;]}</a>";
    }

}

echo displayPath(4,&#39;cate.php?p=1&cid=&#39;);
Copy after login

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!

Related labels:
php
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template