Results 1 to 3 of 3

Thread: How can I get nested replies to work

  1. #1
    TwistedPair Guest

    Default How can I get nested replies to work

    This is really an sql question I think.
    I'm trying to write a comments system for a website, everything works except I can't figure out how to nest replies.
    for example this is what I have now, comments are ordered by the table id

    Post1:"qwerty"
    Post2:"qwerty"
    Post3:"qwerty"
    Reply1:"ytrewq"

    However if there is a reply to the first post I want it to appear below that post

    Post1:"qwerty"
    Reply1:"ytrewq"
    Post2:"qwerty"
    Post3:"qwerty"

    Thats where I'm stuck, I tried creating a second key in the table containing the id of the first comment but i dunno, thats not working out.
    This is all in the same table.

  2. #2
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    In SQL the query would be something like
    ORDER BY id1, id2
    This would put all id1's together, then sort id2's within that group.
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  3. #3
    TwistedPair Guest

    Default

    Thanks, I had the id's in the wrong order, must be tired. Works like a charm now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •