JJR512
08-09-2002, 04:12 AM
I have some code that generates a "|"-separated list of forums that users are able to see. If a user has access to the forum, it appears in the list; if he/she doesn't, it doesn't. But the way I have it now, the | character appears after every forum name. I'd like it to not appear after the last forum name. I think I need to have some way of telling if a while loop is on the last go-round, if you know what I mean...if it's the last time the loop is going to execute.
Here's what I have:
// Begin Forumlinks
$forumlinksperms=$DB_site->query("SELECT forumid,title,parentid FROM forum WHERE active='1' ORDER BY displayorder");
$forumlink = "";
while ($forumlinksperm=$DB_site->fetch_array($forumlinksperms)) {
$getperms=getpermissions($forumlinksperm[forumid]);
if ($getperms[canview]) {
if ($forumlinksperm[parentid]=='-1') {
$forumlink .= "<b>$forumlinksperm[title]</b> | ";
} else {
$forumlink .= "$forumlinksperm[title] | ";
}
}
}
// End Forumlinks
So, if I had, say, five forums, named Forum1, Forum2,...Forum5, and assuming all were accessible, you would see this:
Forum1 | Forum2 | Forum3 | Forum4 | Forum5 |
I'd like to make it so you see this:
Forum1 | Forum2 | Forum3 | Forum4 | Forum5
How can I do this?
Here's what I have:
// Begin Forumlinks
$forumlinksperms=$DB_site->query("SELECT forumid,title,parentid FROM forum WHERE active='1' ORDER BY displayorder");
$forumlink = "";
while ($forumlinksperm=$DB_site->fetch_array($forumlinksperms)) {
$getperms=getpermissions($forumlinksperm[forumid]);
if ($getperms[canview]) {
if ($forumlinksperm[parentid]=='-1') {
$forumlink .= "<b>$forumlinksperm[title]</b> | ";
} else {
$forumlink .= "$forumlinksperm[title] | ";
}
}
}
// End Forumlinks
So, if I had, say, five forums, named Forum1, Forum2,...Forum5, and assuming all were accessible, you would see this:
Forum1 | Forum2 | Forum3 | Forum4 | Forum5 |
I'd like to make it so you see this:
Forum1 | Forum2 | Forum3 | Forum4 | Forum5
How can I do this?