Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5954533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:59:05+00:00 2026-05-22T17:59:05+00:00

Can you help me get this breadcrumb navigation work. My php is not good.

  • 0

Can you help me get this breadcrumb navigation work. My php is not good. i am still learning.

This is my cats in mysql

cats_id   cats_position   cats_parentid 

1            1>                0
2            1>2>              1
3            3>                0
4            1>2>4>            2

I tried something like this but it is not the proper way. Can you please show me the proper way.

$pieces = explode(">", $position);

if ($pieces[0] != "")
{

 $result = mysql_query("SELECT * FROM cats
 WHERE cats_id='$pieces[0]'");
 while($row = mysql_fetch_array($result))
   {
$piecesid0 = $row['cats_id'];
$piecesname0 = $row['cats_name'];
$piecesposition0 = $row['cats_position'];
   }
}
if ($pieces[1] != "")
{
 $result = mysql_query("SELECT * FROM cats
 WHERE cats_id='$pieces[1]'");
 while($row = mysql_fetch_array($result))
   {
$piecesid1 = $row['cats_id'];
$piecesname1 = $row['cats_name'];
$piecesposition1 = $row['cats_position'];
   }
}
if ($pieces[2] != "")
{
 $result = mysql_query("SELECT * FROM cats
 WHERE cats_id='$pieces[2]'");
 while($row = mysql_fetch_array($result))
   {
$piecesid2 = $row['cats_id'];
$piecesname2 = $row['cats_name'];
$piecesposition2 = $row['cats_position'];
   }
}
if ($pieces[3] != "")
{
 $result = mysql_query("SELECT * FROM cats
 WHERE cats_id='$pieces[3]'");
 while($row = mysql_fetch_array($result))
   {
$piecesid3 = $row['cats_id'];
$piecesname3 = $row['cats_name'];
$piecesposition3 = $row['cats_position'];
   }
}
?>
<a href="index.php">Index</a> > 

<a href="cats.php?cat=<?=$piecesid0;?>&parent=0&position=<?=$piecesposition0;?>"><?=$piecesname0;?></a>

<?
If ($piecesid1 != "")
{
?>
> <a href="cats.php?cat=<?=$piecesid1;?>&parent=<?=$piecesid0;?>&position=<?=$piecesposition1;?>"><?=$piecesname1;?></a>
<?
}
?>
<?
If ($piecesid2 != "")
{
?>
> <a href="cats.php?cat=<?=$piecesid2;?>&parent=<?=$piecesid1;?>&position=<?=$piecesposition2;?>"><?=$piecesname2;?></a>
<?
}
?>
<?
If ($piecesid3 != "")
{
?>
> <a href="cats.php?cat=<?=$piecesid3;?>&parent=<?=$piecesid2;?>&position=<?=$piecesposition3;?>"><?=$piecesname3;?></a>
<?
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:59:06+00:00Added an answer on May 22, 2026 at 5:59 pm

    Take a look here at the nested set model:
    http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

    This is how CakePHP implemented the Tree behavior, which is what I use for breadcrumbs. They added the parent_id column as an enhanced version of nested set.

    If that is too heavy weight, you can use the Adjacency List Model: http://kod34fr33.wordpress.com/2008/05/06/adjacency-list-tree-on-mysql/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please help me get this to work? I am trying not to
I just cannot get this to work, would appreciate if someone can help. So
Could someone please help explain why I can't get this to work? I properly
can someone please help me get this simple countdown timer to work, firebug is
I was wondering if anyone can help me to get this code working...? <?php
I can't get my progress bar to work. Any help is much appreciated! Here's
maybe you can help me get this right. I have a class that is
I'm really hoping that someone can help. I have tomorrow to get this right
I am hoping that I can get some help with my learning and find
Can you please help to get this code for SQL? I have column name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.