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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:42:23+00:00 2026-06-11T19:42:23+00:00

In my website, user’s can update and other can comment on the updates, as

  • 0

In my website, user’s can update and other can comment on the updates, as usual like other social networking websites..

What am doing :

query = fetches first name, last name, user id, update id, update post UNION same details for the user who has logged in i.e /* Updates Of Current Logged In User + Updates Of People He Is Following */

loop {
prints first name last name and update
}

later I introduced commenting feature so now what I do is in the loop I call a query and run a loop again for comments..

loop {
prints first name last name and update

commentquery = fetches firstname, last name, user id, comment, of the particulat post
    again loop {
         prints first/last name of the person who commented, and his comment
     }
}

Now according to me I guess this can be accomplished with the SQL query, that when I retrieve posts, I can fetch it’s comments along with it, or is this the right way? the problem is when the outer loop runs, the inner loop also runs to fetch the appropriate comments, so can I join tables to retrieve the comments related to posts/updates?

  • 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-06-11T19:42:24+00:00Added an answer on June 11, 2026 at 7:42 pm

    This is very difficult to answer without your database structure or actual SQL but I have tried to generalise as much as possible. What you are trying to do should be done via SQL with two queries and one loop, something like below.

    Edit Your fine looping and re-executing the query. You CAN fetch all this data in one go with SQL but you will duplicate allot of information in each call. For scalability and readability I would stick with two queries and two loops

    /** updated after op's comments **/
    
    SELECT data, that, you, want, for, one, post
    FROM posts AS a
    INNER JOIN users AS b ON b.id = a.user_id
    
    loop over query results () {
    
        /** output the post data **/
    
        /** Then select the users who have posted on this post **/
        SELECT a.comments, b.username
        FROM comments AS a
        INNER JOIN users AS b ON b.id = a.id
        INNER JOIN posts AS c ON c.id = a.post_id AND c.post_id = '[post id value]'
        ORDER BY a.date_posted;
    
        loop comments here {
          /** output comments here **/
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to build a website where user can post on of their
I want in my wordpress website that user can log in through their facebook
Our website runs the user's input via HtmlTidy to clean it. Apparently while doing
We have a website wherein a user can post information from our website to
I would like to change the place my website redirects user when they are
in my website user can add HTML content with WYSIWYG control . and i
I am creating a website where user can upload video's audio's in different formats
Using Magento i want to create website where user can upload their products to
I would like to give the opportunity to post a comment to my website
I'm developing a website where user's can create calendars and then add events to

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.