如何制作包含长尾关键词的PHP面包屑导航?

2026-04-05 06:058阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计641个文字,预计阅读时间需要3分钟。

如何制作包含长尾关键词的PHP面包屑导航?

1. [文件] position.sql ~ 2KB 下载 (15) + -- 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'

如何制作包含长尾关键词的PHP面包屑导航?

1.[文件] position.sql~2KB 下载(15)

-- phpMyAdmin SQL Dump -- version 3.2.0.1 -- 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, '', '', '');

2.[文件] mysql.php~418B 下载(12)

<?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; } } ?>

3.[文件] position.php~1KB 下载(11)

<?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" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="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>

本文共计641个文字,预计阅读时间需要3分钟。

如何制作包含长尾关键词的PHP面包屑导航?

1. [文件] position.sql ~ 2KB 下载 (15) + -- 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'

如何制作包含长尾关键词的PHP面包屑导航?

1.[文件] position.sql~2KB 下载(15)

-- phpMyAdmin SQL Dump -- version 3.2.0.1 -- 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, '', '', '');

2.[文件] mysql.php~418B 下载(12)

<?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; } } ?>

3.[文件] position.php~1KB 下载(11)

<?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" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="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>