I'm beginner of Php .. I Develop my first dynamic website -> http://wwww.afrogfx.com
if you look at my sidebar you will see categories list my problem located here if i create sub sub categories like that

    CAT A
    - SUB CAT A-1
    - SUB CAT A-2
      -- SUB CAT A-3 ( problem Here )
    CAT B
    - SUB CAT B-1
    - SUB CAT B-2
    - SUB CAT B-2-a
      -- SUB CAT B-2-b ( problem Here )
       --- SUB CAT B-3 ( problem Here )

categories list code

    <?php 
    mysql_select_db($db_name, $conn); // Change for your database  
    $query_Recordset1 = "SELECT catid,catname,parentid FROM categories ";
    $Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error()); // Change for your database


    while ( $row = mysql_fetch_assoc($Recordset1) )
    {
    $menu_array[$row['catid']] = array('catname' => $row['catname'],'catid' =>         $row['catid'],'parentid' => $row['parentid']);

    }
    //recursive function that prints categories as a nested html unordered list

    function generate_menu($parent)
    {
    $has_childs = false;
    //this prevents printing 'ul' if we don't have subcategories for this category
    global $menu_array;
    //use global array variable instead of a local variable to lower stack memory         requierment
    foreach($menu_array as $key => $value)
    {
    if ($value['parentid'] == $parent) 
    {       
    //if this is the first child print '<ul>'                       
    if ($has_childs === false)
    {
    //don't print '<ul>' multiple times                             
    $has_childs = true;
    //echo '<ul>';
    echo '<ul id="categories">';
    }
    echo '<li><a href="categories?catid=' . $value['catid'] . '&parentid=' .                 $value['parentid'] . '&catname=' . $value['catname'] .'">' .         $value['catname'] . '</a>';
    echo '<input type="hidden" value="' . $value['catname'] . '" />';
    generate_menu($key);

    //call function again to generate nested list for subcategories belonging to this         category

    echo '</li>';
    }
    }

    if ($has_childs === true) echo '</ul>';
    }
    //generate menu starting with parent categories (that have a 0 parent)
    ?>

now i need function to select all topic in main category when i select it and sub category to & sub sub category !! how can i do it ?? !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.