> Hi list!

>   I have maybe an easy to solve problem, but I haven't come with a logical
> way to do it. I am builing a discussion site (a la Kuro5hin.org), and
> there's a sql query to retrieve comments attached to an article. It grabs
> their titles, along with some more informatio. What I want is to display the
> comments and the replies below them. It's been implemented in thousands of
> other scripts, but I can't figure out how to do with only one sql query
> (even if it uses Joins). That's important, since I expect the site to be
> very popular here in Brazil (let's hope!)

>   So, any advices about how to display the comments like this:

> - Comment 1
>   - Comment 2
>     - Comment 3

>   Is greatly appreciated. I am thinking about storing all comments in an
> array and construct the layout from there. But still, I don't know if it's
> the best choice in performance terms.

>   Thanks,

> --
> Julio Nobrega.

> Tô chegando:
> http://www.inerciasensorial.com.br

Hi Julio,

maybe you should give a new comment a unique index-number and store this
in your SQL-table with every comment. 

So when somebody is continueing the thread, you give his comment the same
index number as the toplevel comment.

When doing this you can receive all comments within a thread with the
SQL-query : SELECT * FROM <your comment table> WHERE index=...

Now you can get all seperated comments out of your SQL-result array using
a simple loop. 

Good luck!

René Visser

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to