I've only got pseudocode at the moment, but so far i've got something like....
posts database:
id, datetime, replyto, userid, content
1, 13/01/2009, NULL, 1, "blah blah blah"
2, 13/01/2009, NULL, 1, "kjhsad"
3, 14/01/2009, 1, 1, "asd asd asd"
which i'd like to display as
POST 1
POST 3(reply to post 1)
POST 2 (new post)
So far i'm looking at something like....
SELECT * FROM posts WHERE replyto = NULL
foreach{
echo "content id=1"
ifexists (posts entry with replyto=1)
echo "content id=2"
if exists(posts entry with replyto=2)
etc....
}
But it's getting this bit to loop nicely that I'm having problems with.
I had naively hope to be able to use some kind of recursive function like
writePost(){
echo "post content"
if (reply exists){
writePost($replyid);
}
}
but that doesn't appear to be an option and it also involves an SQL query for each entry, which seems a bit excessive.