I've been having a little trouble with a foreach code. I've tried using some principles I thought I had learned in a previous thread, but when I use the foreach loop it only loops once, when it should loop through the entire array (should return 3 times with the 3 rows its pulling from the sql database).
Is this a problem caused by nesting the foreach loop inside the while loop?
while($forums[] = mysql_fetch_array($forums_result))//feed sql data into array
while ($groups = mysql_fetch_array($groups_result)) {
echo "<tr><td colspan=\"5\" class=\"heading\"><img src=\"images/spacer.gif\"
width=\"15\" height=\"1\">".$group['group_name']."</td></tr>";
foreach ($forums as $forum) {
if ($forum['group_id'] == $group['group_id'])
{
echo "<tr align=\"left\" valign=\"top\">";
echo "<td align=\"center\" valign=\"middle\" bgcolor=\"#4F5249\"><img src=\"images/icon_sticky_darkgreen.gif\" width=\"23\" height=\"20\"></td>";
echo "<td bgcolor=\"#4F5249\"><a href=\"#\">".$forum['forum_name']."</a><br>";
echo "this is the forum description</td>";
echo "<td align=\"center\" bgcolor=\"#4F5249\">1203</td>";
echo "<td align=\"center\" bgcolor=\"#4F5249\">4032</td>";
echo "<td bgcolor=\"#4F5249\"> </td>";
echo "</tr>";
}
}
}