Heim >php教程 >php手册 >php 面包屑导航

php 面包屑导航

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:39:161892Durchsuche

无详细内容 -- phpMyAdmin SQL Dump-- version 3.2.0.1-- http://www.phpmyadmin.net---- 主机: localhost-- 生成日期: 2015 年 08 月 13 日 04:42-- 服务器版本: 5.5.8-- PHP 版本: 5.3.3SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";/*!40101 SET @OLD_CHARACTER

-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2015 年 08 月 13 日 04:42
-- 服务器版本: 5.5.8
-- PHP 版本: 5.3.3

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- 数据库: `position`
--

-- --------------------------------------------------------

--
-- 表的结构 `web_about`
--

CREATE TABLE IF NOT EXISTS `web_about` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `title` varchar(60) NOT NULL,
  `content` text NOT NULL,
  `descs` varchar(200) NOT NULL DEFAULT '',
  `pid` mediumint(8) NOT NULL DEFAULT '0',
  `ord` mediumint(4) NOT NULL DEFAULT '10',
  `is_lower` smallint(2) NOT NULL DEFAULT '0',
  `is_delete` smallint(2) NOT NULL DEFAULT '1',
  `seoTitle` varchar(100) NOT NULL DEFAULT '',
  `seoKeyword` varchar(100) NOT NULL DEFAULT '',
  `setDescription` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;

--
-- 转存表中的数据 `web_about`
--

INSERT INTO `web_about` (`id`, `title`, `content`, `descs`, `pid`, `ord`, `is_lower`, `is_delete`, `seoTitle`, `seoKeyword`, `setDescription`) VALUES
(1, '关于我们', '', '', 0, 10, 1, 1, '', '', ''),
(2, '公司简介', '', '', 1, 10, 0, 1, '', '', ''),
(3, '企业文化', '', '', 1, 10, 0, 1, '', '', '');

<?php
class mysql {


   public function __construct()
	{
		$my_db = mysql_connect('localhost','root','');
	    mysql_select_db("position", $my_db);
	    mysql_query("set names 'utf8'");
	}
	
	function row($table,$where='',$alt = '*'){
	    $row = array();
		$sql = "select $alt from $table where $where";
		$query = mysql_query($sql);
		$row = mysql_fetch_assoc($query);
		return $row;
	}
	
}
?>

<?php
include('mysql.php');
class positions extends mysql{

		var $position = array();
		
		function position($id = 0,$url = ''){
			
			$row = $this->row("web_about","id = $id","id,title,pid");
			$this->position[$row['title']] = $url.$row['id'];
			if($row['pid'] !=0){
			 $this->_position($row['pid'],$url);
			}
			$this->position['首页'] = '/';
			return array_reverse($this->position);
		}
		
		function _position($id = 0,$url = ''){
			$row = $this->row("web_about","id = $id","id,title,pid");
			$this->position[$row['title']] = $url.$row['id'];
			if($row['pid'] !=0){
			 $this->_position($row['pid'],$url);
			}
		}
}

function catpos($id,$url,$tag = ' > '){
	$po = new positions();
	$p ='';
	$res = $po->position($id,$url);
	foreach($res as $k=>$v){
	if($k){
	    $p .='<a href="'.$v.'">'.$k.'</a>'.$tag;
	  }
	}
	$p = rtrim($p,$tag);
	return $p;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php 面包屑导航</title>
</head>
<body>
<div>
<ul>
<li><a href="position.php?id=1">关于我们</a>
<ul>
<li><a href="position.php?id=2">公司介绍</a></li>
<li><a href="position.php?id=3">企业文化</a></li>
</ul>
</li>
</ul>
<?php $id = isset($_GET['id'])? intval($_GET['id']) : 1; echo catpos($id,'position.php?id='); ?>
</div>
</body>
</html>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php+ajax 城市联动Nächster Artikel:极简图床curl上传图片