Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4123588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:37:49+00:00 2026-05-20T23:37:49+00:00

Okay, after pounding my head against the wall for about 2 hours, I need

  • 0

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'];
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:37:50+00:00Added an answer on May 20, 2026 at 11:37 pm
    $sqlb ="SELECT myfriend_ID FROM friends WHERE my_id = '$myuid'";
    $resultb = mysql_query($sqlb,$db);
    $follower = array();
    
    if(mysql_num_rows($resultb))
    {
       while(($follower = mysql_fetch_assoc($resultb))) {
          $fnum = $follower['myfriend_ID'];//what is the column name
          $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);
          if( mysql_num_rows($result))
          {
             while(($feed = mysql_fetch_assoc($result))) {
               echo $feed['comment'];
           }
        }
    }
    

    And you must combine these two queries into single. But I am not too good in SQL.
    Probably some one other can help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem I have is that after logging in, and pressing OKAY in safari.
Okay, next PHPExcel question. I have an HTML form that users fill out and
okay, i'm setting up a multi-user chat system. i have a messages table, that
Okay, I have looked everywhere and tried almost every suggestion that I could find
Okay, I have an app that tells me what color of pixel I touched
I'm pounding my head against this. Once every 5-10 times I reload my app,
Okay so here's the situation. I have this page of data. After the data
Okay, So I have a PHP file that uploads a image to my server.
After learning from this question that in C++ It is okay to put the
Hmmm. Okay after revisiting PInvoke, I'm sure that I don't quite get it :-/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.