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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:45:52+00:00 2026-06-11T23:45:52+00:00

I have a small social network site which allows users to make comments on

  • 0

I have a small social network site which allows users to make comments on posts. I can display records based on the friends users have added using SQL. However, I want the comment made on each post to be shown directly below the post.

Post table:

all_id(PK), name, comment, time, expand

Comments table:

post_id, name, comment, all_id(FK)

I’m trying to replicate the functionality of Facebook: commenting on a post and seeing the post right below it. I have tried using a complex SQL join but it didn’t show any data.

  • 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-11T23:45:53+00:00Added an answer on June 11, 2026 at 11:45 pm

    While you could grab the post and all comments in a single query, the result set may be un-foreseeably large, in which case you may exhaust your database’s, your script’s or your server’s memory. But if you wish to do so, let me know and I can post an example.

    Alternately, you could use two separate queries. The first would grab the post, the second would grab all comments relating to that post. Here is an example using PHP and mySQL:

    // Connect to MySQL Database
    $db = mysql_connect('my_host', 'my_username', 'my_password');
    mysql_select_database('my_database', $db);
    // Query for Posts from a specific user.
    $grabPost = mysq_query("SELECT all_id, name, comment, time, expand FROM posts WHERE name = 'some_user_name'", $db);
    // Iterate over each post
    while($post = mysql_fetch_assoc($grabPost)) {
        print '<b>' . htmlentities($post['name']) . '</b> - <i>' . $post['time'] . '</i><br />';
        print htmlentities($post['comment']);
        print '<br />';
        // Query for Comments relating to this Post
        $grabComments = mysql_query("SELECT post_id, name, comment FROM comments WHERE all_id = " . $post['all_id'], $db);
        // Iterate over each comment
        while($comment = mysql_fetch_assoc($grabComments)) {
            print '<p><b>' . htmlentities($comment['name']) . '</b> Says: ' . htmlentities($comment['comment']) . '</p>';
        }
        print '<hr />';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's take for example a small social network site. One of modules are also
I have a small card game at Facebook (and few Russian social networks), which
I have small jquery script which allows me to load external html content by
I have small script in bash, which is generating graphs via gnuplot. Everything works
I'm building a small social site, and I want to implement an activity stream
I have a social network for the cystic fibrosis community. There is a section
I have small PHP script which has $query = SELECT MAX(id) FROM `dbs`; //query
Path is a social networking application that allows you to create a small social
I have following problem. I have a team page like this example: http://www.social-markets.de/social-commerce-team.html small
I have small idea to add social to extensions galleries (show suggest via Facebook

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.