Re: [PHP] creating a threaded message system--sorting messages

2006-06-30 Thread Ben Liu
On Jun 30, 2006, at 12:05 AM, Larry Garfield wrote: I've written such a system before more than once. You do the sorting in SQL, and then traverse the data recursively in PHP to build the tree. It's a single SQL query. Check the archives for this list for about 3-4 weeks ago, I

Re: [PHP] creating a threaded message system--sorting messages

2006-06-30 Thread Ben Liu
Hi Larry, Thanks for the help. I was just coming to a similar conclusion last night after reading the warnings on this thread about querying the database recursively. I guess my test data with 7 posts is not a rigorous simulation. :-) I've looked through the posts on the PHP general list

Re: [PHP] creating a threaded message system--sorting messages

2006-06-30 Thread Larry Garfield
On Friday 30 June 2006 07:19, Ben Liu wrote: Hi Larry, I've looked through the posts on the PHP general list going back about 3-6 weeks and can't find the thread you speak of. I searched by your name assuming that you posted into the thread and searched by the string recursive and recursion.

Re: [PHP] creating a threaded message system--sorting messages

2006-06-30 Thread Richard Lynch
On Thu, June 29, 2006 9:11 am, Ben Liu wrote: I'm trying to present the messages to the users in threaded order rather than flat. I'm having a lot of trouble figuring out how to sort the posts so they appear in the correct threaded order. I don't think I can do this purely with a SQL query.

[PHP] creating a threaded message system--sorting messages

2006-06-29 Thread Ben Liu
This question might deviate from PHP into the domain of MySQL but I thought best to post here first. I'm building a message board system with PHP/MySQL. I'm trying to present the messages to the users in threaded order rather than flat. I'm having a lot of trouble figuring out how to sort the

Re: [PHP] creating a threaded message system--sorting messages

2006-06-29 Thread Larry Garfield
On Thursday 29 June 2006 09:11, Ben Liu wrote: relevant data structure loosely: post_id (unique, autoincrement, primary index) parent_id (if the post is a child, this field contains the post_id of its parent) ... 1) Query the database for all messages under a certain topic, sort by