Results 1 to 10 of 10

Thread: [RESOLVED] Forum - Breadcrumb - Parent Forums

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Resolved [RESOLVED] Forum - Breadcrumb - Parent Forums

    Ok i am making a forum, and it allows unlimited sub-forums. How my db is set up, it is has a parentforumID for the parent forum of that forum. (duh).

    If there is no parent forum then it is equal to 0. So i need to do a breadcrumb for this, and i tried using a while loop, but it doesnt seem to work.

    What am i doing wrong?

    PHP Code:
    if ($forums->forumExists($_GET['forumid'])) {
        
    $catID $forums->getCategoryID($_GET['forumid']);
        
    $catname $forums->getCategoryName($catID);
        
    $forumname $forums->getForumName($_GET['forumid']);
        
    $breadcrumb "&gt; <a href='?action=home#cat_{$catID}'>{$catname}</a> ";
        
    $forumID mysql_real_escape_string($_GET['forumid']);
        
    $sql1 "SELECT `parentforumID` FROM `".$db_prefix."forums` WHERE forumID='{$forumID}' LIMIT 1";
        
    $query1 mysql_query($sql1);
        
    $res1 mysql_fetch_array($query1);
        if (
    $res1['parentforumID'] == 0) {
            
    $breadcrumb .= "&gt; {$forumname}";
        } else {
            
    $parentID $res['parentforumID'];
            while (
    $parentID!=0) {
                
    $sql "SELECT     `parentforumID` FROM `".$db_prefix."forums` WHERE forumID='{$parentID}' LIMIT 1";
                
    $query mysql_query($sql) or die(mysql_error());
                
    $res mysql_fetch_array($query);
                
    $name $forums->getForumName($parentID);
                
    $breadcrumb .= "&gt; <a href='?action=viewforum&forumid={$parentID}'>{$name}</a> ";
                
    $parentID $res['parentforumID'];
            }
        }
    } else {
        
    $breadcrumb "&gt; Error";

    My usual boring signature: Something

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Forum - Breadcrumb - Parent Forums

    You need to use a recursive function to produce the breadcrumbs.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Forum - Breadcrumb - Parent Forums

    can you give me an example?
    My usual boring signature: Something

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Forum - Breadcrumb - Parent Forums

    It looks nice to use recursion. But the code above looks ok; so what is the problem?
    PHP Code:
    function breadcrumbs($forumId)
    {
        
    $breadCrumbs '';

        if(
    $parentForum != 0) {
            return 
    $breadCrumbs;
        } else {
            
    /* add new link here */
            
    $breadCrumbs .= breadCrumbs($parentForum);
        }

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Forum - Breadcrumb - Parent Forums

    my code isnt doing anything. It isnt echoing a breadcrumb or any errors.
    My usual boring signature: Something

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Forum - Breadcrumb - Parent Forums

    Use a few echos to find out exactly how far it is getting.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Forum - Breadcrumb - Parent Forums

    ok i tried to do the breadcrumb, and looking at your code, it confuses me...
    My usual boring signature: Something

  8. #8

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Forum - Breadcrumb - Parent Forums

    ahhh! i figured it out. My code was all correct. I just misnamed a variable
    My usual boring signature: Something

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Forum - Breadcrumb - Parent Forums

    Quote Originally Posted by dclamp
    ahhh! i figured it out. My code was all correct. I just misnamed a variable
    That's why you should always ensure you have error reporting set to E_ALL.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: [RESOLVED] Forum - Breadcrumb - Parent Forums

    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width