Okay, after pounding my head against the wall for about 2 hours, I need help. I have a query that pulls "comments" based on a users "followers". The followers have a unique id, and lets say just for ease of use, their id's are 4 and 5. The query returns all followers, so there could be way more than just two rows. That query creates a foreach that I want to say for each "follower" execute this query. Then, that query needs to create a fetch_assoc() so that the data can be recalled later on down the page. The way I have the code right now, it only shows postings from follower 4, and not 5. I have tried using counters to append variable names so that they wont get overwritten each time, but it doesnt help. Thanks a lot!
$sqlb ="SELECT myfriend_ID FROM friends WHERE my_id = '$myuid'";
$resultb = mysql_query($sqlb,$db);
$numa = mysql_num_rows($resultb);
if($numa)
{
while(($follower = mysql_fetch_assoc($resultb))) {
$followers[] = $follower;
}
}
$i=0;
foreach($followers as $follower)
{
$i++;
$fnub = $follower['myfollower_ID'];//this will print 4 and 5
$fnum = $fnub;
$sql = "SELECT * FROM usr, feed, course WHERE usr.usr_id = '$fnum' AND
feed.usr_id = '$fnum' AND course.usr_id = '$fnum' ORDER BY Feed_ID desc";
$result = mysql_query($sql,$db);
$num.$fnum = mysql_num_rows($result);
if($num.$fnum)
{
while(($feed = mysql_fetch_assoc($result))) {
$feeds[] = $feed;
}
foreach($feeds as $feed)
{
echo $feed['comment'];
}
}
}
$ifor example is completely irrelevant here.