MyBB Community Forums

Full Version: Loops
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I don't know what part of the code it was that made the page look like what it is now, but it made it worse.
Prefixes are echo'ed anywhere from 1 time to, maybe 7 times.
And the groups/[]'s aren't fixed.
The extra []'s are confusing me.
one more time, this time i am reseting the output variable for each prefix and cleaned up the case for all groups

you were also needing to reset the $usergroups variable. it was posting all groups you had ever found.

$prefix_header = "The available prefixes are as followed (Title - Usergroups - Forum ID): <br />";

$prefix = $db->simple_select("threadprefixes",  "*", "1=1");
while ($prefix_result = $db->fetch_array($prefix)) {
    $title = $prefix_result['displaystyle'];
    $fid = $prefix_result['forums'];
    $fid = str_replace(",", ", ", $fid);
    $fid_replace = str_replace("-1", "All Forums", $fid);
    $gid = $prefix_result['groups'];
    $format = "<font color='#4BB1FF'>{$title}</font>";
     $prefix_output = "";
    $usergroups = "";
    if($gid != -1)
    {
       $groups = $db->simple_select("usergroups", "*", "gid in ({$gid})");
        while ($groups_result = $db->fetch_array($groups)) {
            $usergroup = $groups_result['namestyle'];
            $usergroup2 = str_replace("{username}", $groups_result['title'], $usergroup);
            $usergroups .= " [".$usergroup3."] ";
            $prefix_output .= "{$format} - {$usergroups} - {$fid_replace}<br /><br />";
        }
    }
    else
    {
        $prefix_output .= "{$format} - [All Groups] - {$fid_replace}<br /><br />";
    }
}
$prefix_output = $prefix_header.$prefix_output;
 
Thanks for your help, it took a bit of modification, but I was able to get it.
I had to remove the $prefix_output = ""; and put the $usergroups = ""; into the 2nd while loop.
sorry it took so many iterations. i am not setup to properly test that code as i am not running a 1.6 install with any data in it to test against. only going off what i have available right now.

glad you got it working
Pages: 1 2