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

  • Home
  • SEARCH
  • 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 8411381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:24:33+00:00 2026-06-10T00:24:33+00:00

I thought to implement advanced commenting system in my website using PHP-MySql. I finally

  • 0

I thought to implement advanced commenting system in my website using PHP-MySql. I finally settled for a 3-level comment-reply system for this purpose.
Well, for that purpose I came across this article to implement the data-structure of the SQL database.

I planned to use nested set mdoel for the feature I want to use. The structure of the comments are like this-

<ul>
    <li>Parent comment</li>
        <ul>
            <li>First reply of parent comment</li>
            <ul>
                <li>reply of the previous reply</li>
                   <ul>
                       <li>reply of the previous reply</li>
                       <li>another reply of the previous reply</li>
                   </ul>
                <li>another reply of the previous comment</li>
             </ul>
             <li>second reply of the parent comment</li>
        </ul>
</ul>

For this type of structure, I have been playing around with PHP to show the query detecting the parents and its child uniquely(for fetching user details associated with each comment) and produce the output in the manner if shown above. Do anyone have idea how to do it. Please help me out.

EDIT :

I have a seperate user table in SQL linked to the comment table as user.id=comment.id. So considering this, what would be the recommended approach to detect user activity for each comment? I mean, for ex- I want to fetch user name and email for a sub-comment of parent comment 2. Hoow could it be done?

  • 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-10T00:24:34+00:00Added an answer on June 10, 2026 at 12:24 am

    Use the query from “Finding the Depth of the Nodes”, and this PHP code will create the nested lists.

    $cur_depth = -1;
    while ($row = mysqli_fetch_assoc($query)) { // Loop through results of query
      if ($row['depth'] > $cur_depth) {
        echo "<ul>\n";
        $cur_depth = $row['depth'];
      }
      else while ($cur_depth > $row['depth']) {
        echo "</ul>\n";
        $cur_depth--;
      }
      echo "<li>" . $row['comment'] . "</li>\n";
    }
    while ($cur_depth > -1) {
      echo "</ul>\n";
      $cur_depth--;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to implement a Repository and UnitOfWork patterns using Entity Framework. This is
I always thought that if you didn't implement a heartbeat, there was no way
I am trying to implement does_key_exist, I thought the code below would do it.
I have three current thoughts on how to do this: re-implement AuthenticationService, which uses
I helped design and implement and Droid API written in PHP. Though it works
Thought my range of search options would easily find this. I wish to combine
I thought I had resolved this but I obviously haven't and was hoping someone
I've thought long and hard about this and I'm really not sure if it's
I have numerous index.php scripts using SEO-friendly arg format like example.com/path/to/index.php/opt/arg and would like
I've been trying to implement this for a long time and I have gotten

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.