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

<p>This is my cats in mysql</p>

<pre><code>cats_id   cats_position   cats_parentid 

1            1&gt;                0
2            1&gt;2&gt;              1
3            3&gt;                0
4            1&gt;2&gt;4&gt;            2
</code></pre>

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

<pre><code>$pieces = explode("&gt;", $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'];
   }
}
?&gt;
&lt;a href="index.php"&gt;Index&lt;/a&gt; &gt; 

&lt;a href="cats.php?cat=&lt;?=$piecesid0;?&gt;&amp;parent=0&amp;position=&lt;?=$piecesposition0;?&gt;"&gt;&lt;?=$piecesname0;?&gt;&lt;/a&gt;

&lt;?
If ($piecesid1 != "")
{
?&gt;
&gt; &lt;a href="cats.php?cat=&lt;?=$piecesid1;?&gt;&amp;parent=&lt;?=$piecesid0;?&gt;&amp;position=&lt;?=$piecesposition1;?&gt;"&gt;&lt;?=$piecesname1;?&gt;&lt;/a&gt;
&lt;?
}
?&gt;
&lt;?
If ($piecesid2 != "")
{
?&gt;
&gt; &lt;a href="cats.php?cat=&lt;?=$piecesid2;?&gt;&amp;parent=&lt;?=$piecesid1;?&gt;&amp;position=&lt;?=$piecesposition2;?&gt;"&gt;&lt;?=$piecesname2;?&gt;&lt;/a&gt;
&lt;?
}
?&gt;
&lt;?
If ($piecesid3 != "")
{
?&gt;
&gt; &lt;a href="cats.php?cat=&lt;?=$piecesid3;?&gt;&amp;parent=&lt;?=$piecesid2;?&gt;&amp;position=&lt;?=$piecesposition3;?&gt;"&gt;&lt;?=$piecesname3;?&gt;&lt;/a&gt;
&lt;?
}
?&gt;
</code></pre>
