0

Im trying to create a crumb trail for a custom web script that drills down three levels into a link system. there are not many pages so my idea seem less work than to integrate someone else's script !

this is how i mark or identify the page in the header of each page

first level page

<?php $page = 'index_week'; ?>

second level page

<?php $page = 'index_week_list'; ?>

third level page which is also the details page and no deeper levels exist after this

<?php $page = 'index_week_ details'; ?>

My questions are...

1-how do i give each of these a label to that i can show them in the crumb trail and not show ""index_week_ details""

2-how do i link the file name to go back to a previous level with the identifier i used so that it picks up the listing id i used to filter that page's content form the database?

Below the header are and beginning of each page to see my dilemma !

the first lever page

<?php 
include("inc_login_config.php");
include("inc_gen_constants.php");
include("inc_meta_header.php"); 
require("inc_dbsql.php");
include("inc_link_sql.php");
?>
<?php $page = 'index_week'; ?>
</head>
<body marginwidth="0" marginheight="0">
<!-- End of all general inclusuions -->
<?php
$db = new LinkSQL($dbname); 
$homecataresult = $db->getchildcatalog(0);
$table="linkexcatalog";
mysql_connect           ($dbhost,$dbuser,$dbpassword);
@mysql_select_db        ($dbname);
$result = mysql_query("select catalogid,catalogname,parentid from $table where arentid='0' order by priority asc" );
$num_fields = mysql_num_fields($result);
$num_rows = mysql_num_rows($result);
$row_cnt = 0;
while ($num_rows>$row_cnt)
{
$record = @mysql_fetch_row($result); 
?>
<a href="ba_index_list_lessons.php?id=<?php print "$record[0]"; ?>"><?php print "$record[1]"; ?></A><br>
<?php $row_cnt++;} ?>
<?php mysql_close(); ?>

The other Two PHP files looks much the same except i have different LEVEL page id in them ? I hope i don't confuse to much !

Ta any help appreciated.

4

1 回答 1

0

Break up your string (into an array) on _'s, then loop on that array to create the breadcrumbs.

Here's a quick example:

<?php

$me = 'index_week_details';

//Break into an array
$parts = explode('_', $me);

//Debug
//print_r($parts);

//Create breadcrumbs
$path = '';
foreach($parts as $part) {
  $path .= $part . '_';  

  echo '<a href="' . rtrim($path, '_') . '">' . $part . '</a>' . "\n";
}

You can play with it live here:

http://codepad.org/dFpujKZ8

Input:

index_week_details

Output:

<a href="index">index</a>
<a href="index_week">week</a>
<a href="index_week_details">details</a>
于 2013-07-08T18:55:53.063 回答