Hi Debbie,
I am thinking this:
Posts Table (Simplified)
| id |
post |
| 1 |
I think that the problem is ... |
| 2 |
I like Kites, what do you ... |
Comments Table (Simplified)
| id |
comment |
| 1 |
The problem is not what you think... |
| 2 |
I also like Kites, in particular... |
| 3 |
No I agree with your view of the... |
| 4 |
What the F@ck you DINK!!!! |
| 5 |
I build my own kites see my blog ... |
| 6 |
Wow that is a big problem ... |
Comments2Posts (Simplified)
| comment_id |
post_id |
| 1 |
1 |
| 2 |
2 |
| 3 |
1 |
| 4 |
1 |
| 5 |
2 |
| 6 |
1 |
Then this will get all your comments related to each post
Code:
SELECT
c2p.post_id
,c2p.comment_id
, c.comment
FROM
comments as c
INNER JOIN comments2posts as c2p
ON c2p.comment_id = c.id
Order By
post_id, comment_id
Code:
SELECT
id
, post
FROM
posts
Order By
id;
Then:- loop through these comments and put the post_id, comment_id, and comments into an array. After doing this you would have an array or comments arrays
- create a loop to read your posts. Inside this loop you first output the post (or put it into an $html variable) and then loop through comments and where comment's post_id = the post's id you then output this comment (or append it to your $html variable).
By linking your comments this way you don't have to worry about re-ordering or if you implement a way where a user can bookmark an individual comment (like SP currently lets us bookmark a single post by selecting the post id and then bookmarking).
Hope this helps.
Steve
Bookmarks