Category Navigation Bar

Discussion in 'PHP' started by Alam, May 20, 2007.

  1. #1
    Dear Friends,

    I have a category table.

    Category
    ------------------------
    ctegory_id-----parent_id-----category_name
    1-----------------0-------------Sports
    2-----------------0-------------Music
    3-----------------2-------------Rap
    4-----------------2-------------Pop
    5-----------------4-------------Jackson
    6-----------------4-------------Madonna
    7-----------------1-------------Maradona

    I need a navigation bar then ppl can easily understand where is he and can move any catgory any time.

    Home > Music > Pop > Madonna

    Please help me. :(

    Thanks
     
    Alam, May 20, 2007 IP
  2. Alam

    Alam Active Member

    Messages:
    316
    Likes Received:
    91
    Best Answers:
    0
    Trophy Points:
    68
    #2
    I am using following codes for navigation menu

    <?php

    if($category_id==""){
    $category_id=0;
    }

    $c=mysql_query("select * from category where parent_id='$category_id'");
    while($cr=mysql_fetch_array($c)){
    echo "<a href=index.php?category_id=".$cr["category_id"].">".$cr["category_name"]."</a><br>";
    }

    ?>
     
    Alam, May 20, 2007 IP
  3. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #3
    You will have to get child categories of a category recursively. Use a function instead of writing and executing query in mid of code.
     
    designcode, May 21, 2007 IP
  4. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #4
    well,it will be better if you give more explanation.it is not clear at all.
     
    coderbari, May 21, 2007 IP
  5. Hannaspice

    Hannaspice Active Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    Thanks guys,

    it is so good for my tutorial.
     
    Hannaspice, Nov 10, 2009 IP