PHP Framework and Fetch Assoc
I am using a framework, and I am having an issue with getting the results of this particular associative array. All others work except for this one and I am not sure why. This one only returns one result. Here is what I have in my model:
public function listStats($id) {
$sql = DB::inst()->query( "SELECT *
FROM ".
TP."tracking
WHERE
mID = '$id'
GROUP BY
mID"
);
$data = array();
if($sql->num_rows > 0) {
while($row = $sql->fetch_assoc()) {
$data[] = $row;
}
return $data;
}
}
And here is what I have in my view:
<?php foreach($this->listStats as $k => $v) : ?>
<tr>
<td>
<?php echo clean($v['email']); ?>
</td>
</tr>
<?php endforeach; ?>
Any help with figuring this out is greatly appreciated.
Related Article: php uploading multi files into mysql help
is a PHP discussion thread by stevenbeatsmith that has 3 replies, was last updated 1 year ago and has been tagged with the keywords: mysql, php, uploading.
joshmac
Junior Poster in Training
84 posts since Apr 2008
Reputation Points: 16
Solved Threads: 5
Skill Endorsements: 0
Also, since you are querying a specific mID and then grouping by the same field, it's correct to get just a row. So try to change the GROUP BY clause. Bye!
cereal
Veteran Poster
1,145 posts since Aug 2007
Reputation Points: 344
Solved Threads: 222
Skill Endorsements: 22
HMM, the GROUP BY was a later addition because it wasn't working, but removing it makes it work now. Thanks.
joshmac
Junior Poster in Training
84 posts since Apr 2008
Reputation Points: 16
Solved Threads: 5
Skill Endorsements: 0
Question Answered as of 3 Months Ago by
veedeoo
and
cereal