I've a problem with array_push and am hoping for some advice.
PROBLEM:
PHP picks up an array of Group IDs through the $_POST. The goal is to grab multiple Group ID's and use them to grab all members of every Group ID for display. This seems pretty straight-forward, but as things stand now, php is only returning members of the group most recently run through the foreach statement. It makes sense that I have to push the SELECT results into a multi-dimensional array and then process them for display. And that is where I'm getting hung up. Following is the applicable code:
Code: Select all
$GroupResults = Array();
if (!empty($_POST['bind_GrpArray']))
{
foreach($_POST['bind_GrpArray'] as $item)
{
$prep_Groups = $link->prepare($select_OrgGroups);
$prep_Groups->execute(array(
':GrpID'=>$item,
));
$PrepResults = $prep_Groups->fetchAll();
}
$GroupResults = array_push($GroupResults, $PrepResults); // this is where I'm trying to create a multi-dimensional array. It's not working.
}
foreach($GroupResults as $row) //This foreach does NOT return results. Error message from my CPanel says, "Invalid argument supplied for foreach()"
{
echo "<br /> Row: ";
var_dump($row);
echo "<br />";
$member = stripslashes($row['LName']) . ", " . stripslashes($row['FName']);
$memberDate = $row['MemberDate'];
$group = $row['GroupID'];
echo "<tr class='memberRows'>";
echo "<td class='b_lay'>" . $member . "</td>";
echo "<td class='c_lay'>". $MemberDate ."</td>";
echo "</tr>";
}Thanks for the help - in advance:
Pavilion