|
-
Jul 5th, 2008, 11:41 PM
#1
Thread Starter
WiggleWiggle
[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 = "> <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 .= "> {$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 .= "> <a href='?action=viewforum&forumid={$parentID}'>{$name}</a> ";
$parentID = $res['parentforumID'];
}
}
} else {
$breadcrumb = "> Error";
}
My usual boring signature: Something
-
Jul 6th, 2008, 05:29 PM
#2
Re: Forum - Breadcrumb - Parent Forums
You need to use a recursive function to produce the breadcrumbs.
-
Jul 6th, 2008, 05:35 PM
#3
Thread Starter
WiggleWiggle
Re: Forum - Breadcrumb - Parent Forums
can you give me an example?
My usual boring signature: Something
-
Jul 6th, 2008, 06:06 PM
#4
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); } }
-
Jul 6th, 2008, 06:32 PM
#5
Thread Starter
WiggleWiggle
Re: Forum - Breadcrumb - Parent Forums
my code isnt doing anything. It isnt echoing a breadcrumb or any errors.
My usual boring signature: Something
-
Jul 7th, 2008, 12:48 AM
#6
Re: Forum - Breadcrumb - Parent Forums
Use a few echos to find out exactly how far it is getting.
-
Jul 17th, 2008, 10:20 PM
#7
Thread Starter
WiggleWiggle
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
-
Jul 17th, 2008, 10:48 PM
#8
Thread Starter
WiggleWiggle
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
-
Jul 19th, 2008, 09:17 AM
#9
Re: Forum - Breadcrumb - Parent Forums
 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.
-
Jul 19th, 2008, 03:09 PM
#10
Thread Starter
WiggleWiggle
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|