threaded comments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • George Thompson
    New Member
    • Dec 2011
    • 33

    threaded comments

    so i\'ve been trying to build a threaded comments section on my website, with little to no luck trying to figure out how to loop through 2 while loops and load my comments. i\'ve read a lot of different code snippets and comments about this, and seem to get further lost.. here is what im attempting, mysql database looks like this
    id
    profile_id
    parent
    type " 'a', 'b' "
    comment
    datetime
    so far ive tried doing it with one query and one loop, and 2 queries and 2 loops, and i only ever get errors or just one parent and one child.... and i have many parents and many children, but children are only one deep... i dont necessarily need the answeres or someone to do this for me, but maybe someone know a good easy to understand tutorial i can go through to help me unserstand... thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Can you post an example of what you mean by threaded comments?

    Comment

    • George Thompson
      New Member
      • Dec 2011
      • 33

      #3
      I'm not on my computer right now so hope this can help clarify. If not I can try posting some code.
      By threaded comments I'm talking about comments people leave for others. I hate to say it. But. Like facebook. Or better yet like YouTube. Structured like this
      Parent
      Child
      Child
      Parent
      Parent
      Child

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Can't a child also be a parent?

        Comment

        • George Thompson
          New Member
          • Dec 2011
          • 33

          #5
          In some instances they can be. But for what I'm tryingto do I don't want children to be parents

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            I suppose you would do something like this
            Code:
            sql = "select parents from comments"
            
            for each row in sql
               output sql.comment
               sql2 = "select children from comments where parent = " + sql.parent
               
               for each row in sql2
                  output sql2.comment
               next
            next

            Comment

            • George Thompson
              New Member
              • Dec 2011
              • 33

              #7
              thats it... thank you so much. i tweaked it a little but thats it, and its working great... :D

              Comment

              • omerbutt
                Contributor
                • Nov 2006
                • 638

                #8
                you must select the right answer to the question if you think he has provided you with the solution , so that this could be helpful to any one else who comes here googling.
                regards,
                Omer Aslam

                Comment

                Working...