MyBB Community Forums

Full Version: While Query Only Outputting 1 Row (2 Recorded in Database)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm attempting to throw out a link to all the posts made by the users account from the member_profile template. What I have thus far is the following:
        $icgroups_sql = "
            SELECT p.pid, p.fid, p.uid
            FROM ".TABLE_PREFIX."posts p
            WHERE p.fid = 16
            AND p.uid = $uid
        ";
        $icgroups_result = $db->query($icgroups_sql);
        while ($icgrecords = $db->fetch_array($icgroups_result)) {

            eval('$icgrouplist = "' . $templates->get('member_profile_icgrouplist') . '";');
        }

The $icgrouplist variable is put inside member_profile.

Inside the member_profile_icgrouplist template I have entered the following for testing purposes.
<div>{$icgrecords['pid']}</div>

From my understanding PID 1362 AND 1363 should both pop up in their own divs. However, only 1363 shows. I was under the impression that the while loop would spit out the member_profile_icgrouplist template twice but it is only doing it once and choosing the most recent post ID.
[attachment=46268]

When I run this exact query in phpMyAdmin (see attachment, using the UID manually of the profile I've been testing with) both posts show up. So why is the while loop not doing while loop things for the fetched array?...

[attachment=46267]
You need a .=, not just an =, after $icgrouplist in your eval().
Well that did the trick, thank you for finding that!