hyperlink - How do I change recursive php breadcrumbs into links?


I'm working an a shopping cart with a page called display.php. This page is called repeatedly as you go through the navigation, always calling itself but querying for new, more specific things. I am trying to make breadcrumbs that will provide links to previous pages, but it's proving to be tricky.

This part of display.php retrieves "id", which the query uses to find things, and breadcrumbs, which is the previous breadcrumbs string. "id" is always added to the breadcrumbs string.

$id = $_GET['id'];
$breadcrumbs = $breadcrumbs." > ".$id;
echo $breadcrumbs

As the id variable is used to query for things, links are generated to go to display.php all over again but to query for something new and take the breadcrumbs string with it.<a href="http://www.myurl.com/display.php?id='.$name.'&depth='.$sub_level.'&breadcrumbs='.$breadcrumbs.'"><img src="imagen/logo1.jpg" alt="" width="100" height="100" /><br>'. $name . '</a>

Each time I go to a new page, the breadcrumbs display visibly, but how can I safely change these string statements into links? an can't carry another string inside it safely. I think it's possible if I explode the breadcrumb string with the > character as the delimiter. How can I fix this up so it will display nice links in the breadcrumb string?

    $breadlist = explode(" > ", $breadcrumbs);

    $linkarray = array();
    foreach $breadlist as $breadlink
        $linkarray($j) = "<a href=display.php?id=".$breadlink($j)."?breadcrumbs=".$breadcrumbs.">".$breadlist($j)."";

People are also looking for solutions to the problem: php - module to display external db articles category


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.