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 6796039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:25:09+00:00 2026-05-26T18:25:09+00:00

I m trying to make feed system for my website, in which i have

  • 0

I m trying to make feed system for my website, in which i have got i data from the database using mysql_fetch_array system and created a while loop for mysql_fetch_array and inside that loop i have repeated the same thing again another while loop, but the problem is that the nested while loop only execute once and dont repeat the rows…. here is the code i have used some function and OOP but u will get what is the point!
i thought of an alternative but not yet tried vaz i wanna the way out this way only i.e. using a for loop instead of while loop that might work…

public function get_feeds_from_my_friends(){
    global $Friends;
    global $User;
    $friend_list = $Friends->create_friend_list_ids();
    $sql = "SELECT feeds.id, feeds.user_id, feeds.post, feeds.date FROM feeds WHERE feeds.user_id IN (". $friend_list. ") ORDER BY feeds.id DESC";
    $result = mysql_query($sql);
    while ($rows = mysql_fetch_array($result)) {
            $id = $rows['user_id'];
            $dp = $User->user_detail_by_id($id, "dp");
            $user_name = $User->full_name_by_id($id);
            $post_id = $rows['id'];

            $final_result = "<div class=\"sharedItem\">";
            $final_result .= "<div class=\"item\">";
            $final_result .= "<div class=\"imageHolder\"><img src=\"". $dp ."\" class=\"profilePicture\" /></div>";
            $final_result .= "<div class=\"txtHolder\">";
            $final_result .= "<div class=\"username\"> " . $user_name  . "</div>";
            $final_result .= "<div class=\"userfeed\"> " . $rows['post'] . "</div>";
            $final_result .= "<div class=\"details\">" . $rows['date'] . "</div>";
            $final_result .= "</div></div>";
            $final_result .= $this->get_comments_for_feed($post_id);
            $final_result .= "</div>";

            echo $final_result;
        }
}

public function get_comments_for_feed($feed_id){
    global $User;

    $sql = "SELECT feeds.comments FROM feeds WHERE feeds.id = " . $feed_id . " LIMIT 1";
    $result = mysql_query($sql);
    $result = mysql_fetch_array($result); 
    $result = $result['comments'];
    $comment_list = get_array_string_from_feild($result);

    $sql = "SELECT comment_feed.user_id, comment_feed.comment, comment_feed.date FROM comment_feed ";
    $sql .= "WHERE comment_feed.id IN(" . $comment_list . ") ORDER BY comment_feed.date DESC";
    $result = mysql_query($sql);
    if(empty($result)){ return "";}
    else {
        while ($rows = mysql_fetch_array($result)) {
                $id = $rows['user_id'];
                $dp = $User->user_detail_by_id($id, "dp");
                $user_name = $User->full_name_by_id($id);
                return "<div class=\"comments\"><div class=\"imageHolder\"><img src=\"". $dp ."\" class=\"profilePicture\" /></div>
                            <div class=\"txtHolder\">
                                <div class=\"username\"> " . $user_name  . "</div>
                                <div class=\"userfeed\"> " . $rows['comment'] . "</div>
                                <div class=\"details\">" . $rows['date'] . "</div>
                            </div></div>";

        }       

    }
}
  • 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-26T18:25:09+00:00Added an answer on May 26, 2026 at 6:25 pm

    It’s because you’re using return, which stops the function from further executing. What you’re trying to do is

    //...
    else {
        $out = '';
        while ($rows = mysql_fetch_array($result)) {
                $id = $rows['user_id'];
                $dp = $User->user_detail_by_id($id, "dp");
                $user_name = $User->full_name_by_id($id);
                $out .= "<div class=\"comments\"><div class=\"imageHolder\"><img src=\"". $dp ."\" class=\"profilePicture\" /></div>
                            <div class=\"txtHolder\">
                                <div class=\"username\"> " . $user_name  . "</div>
                                <div class=\"userfeed\"> " . $rows['comment'] . "</div>
                                <div class=\"details\">" . $rows['date'] . "</div>
                            </div></div>";
    
        }
        return $out;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an app that parses data from Twitter using JSON
I am trying to make an Android app which will pull uploaded videos from
I'm trying to make a News Feed and I'm stuck. Let's say I have
I have been trying to make wall post from multiple pages but when i
Im trying to make a twitter feed for my website, however, I want do
Trying to make a generic PL/SQL procedure to export data in specific XML format,
Trying to make a custom :confirm message for a rails form that returns data
trying to make a page which will recursively call a function until a limit
While trying to make one of my python applications a bit more robust in
After trying to make a while(bool) loop and it failing because I couldn't see

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.