我设法解决了它我需要的,它不是那么难
function breadcrumb(
$home = 'Home', // Name of root link
$division = ' / ', // Divider between links
$hidextra = true, // Toggle hide/show get data and fragment in text
$index = false, // Toggle show/hide link to directory if it does not contain a file
$indexname = 'index.php' // The definition of the file the directory must contain
) {
global $host,$dbUser,$dbPass,$dbName;
require_once("php/database/connection.php");
require_once("php/database/MySQL.php");
// Connect to the database and grab the email
$db = & new MySQL($host,$dbUser,$dbPass,$dbName);
$breadcrumb="";
// Requested addons...
$extension = '.php'; // Extension to cut off the end of the TEXT links
$ifIndex = 'index.php'; // Filename of index/default/home files to not display
// End requested addons
$whole = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$parts = explode('/', $whole);
$parts[0] = 'http://'.$parts[0];
$array = array('-', '%20');
$breadcrumb .= "<a href=\"{$parts[0]}\">{$home}</a>{$division}";
$k = 1;
for ($i=1;$i < sizeof($parts);$i++) {
$uri = '/';
while ($k <= $i) {
$uri .= $parts[$k];
if ($k != (sizeof($parts)-1)) $uri .= '/';
$k++;
}
if (($index && is_dir($_SERVER['DOCUMENT_ROOT'].$uri) && is_file($_SERVER['DOCUMENT_ROOT'].$uri.$indexname)
|| !$index
|| !is_dir($_SERVER['DOCUMENT_ROOT'].$uri)) && $parts[$i] != $ifIndex) {
$breadcrumb .= "<a href=\"$uri\">";
if ($hidextra) {
if($parts[$i-1]=="forum") {
$board = substr($parts[$i],6);
$sql = "SELECT boardname FROM boards WHERE boardid='".$board."'";
$result = $db->query($sql);
while($row=$result->fetch()) {
extract($row, EXTR_PREFIX_INVALID, '_');
$breadcrumb .= $boardname;
}
}
else if($parts[$i-2]=="forum") {
$topic = substr($parts[$i],10);
$sql = "SELECT topicname FROM topics WHERE topicid='".$topic."'";
$result = $db->query($sql);
while($row=$result->fetch()) {
extract($row, EXTR_PREFIX_INVALID, '_');
$breadcrumb .= $topicname;
}
}
else {
$breadcrumb .= rtrim(preg_replace("/\?.*$/", '', ucwords(str_replace($array," ",$parts[$i]))), $extension);
}
}
else {
$breadcrumb .= rtrim(ucwords($parts[$i]), $extension);
}
$breadcrumb .= '</a>';
}
else {
$breadcrumb .= ucwords(str_replace($array," ",$parts[$i]));
}
if (isset($parts[($i+1)])) {
$breadcrumb .= $division;
}
$k = 1;
}
return $breadcrumb;
}
我必须检查当前的部分,如果以前是'论坛',建立一个连接到数据库,抓取我需要的信息,然后更换什么是在面包屑在这一点上。下一个面包屑也是这样。
现在它应该怎样工作。