php如何实现全路径无限分类导航(代码)

首页 编程分享 PHP丨JAVA丨OTHER 正文

不言 转载 编程分享 2019-02-24 01:02:31

简介 如何实现数组归并排序并计算逆序对的个数(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。


本篇文章给大家带来的内容是关于php如何实现全路径无限分类导航(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
<?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=');

转载链接:http://www.php.cn//php-weizijiaocheng-411249.html


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云