Hello, I'm trying to make a facebook wall-alike php script.
It loads the posts stuff, photo url and user stuff like username and user id from my MySQL database. It also checks if the post is just a comment to another post (parentof). I can present all the original posts with pictures with a simple do-while using tags .
But how could I present the comments under every post? I guess with another do-loop, but how?
That sounds like a good idea, but not so well organized i guess.
That's why I separated comments into another table.
So now I got tables:
users, wall, comments.
Is there any way to loop and print comments to all posts? any other way?
SELECT users.*, wall.*, IF(wall.parentof = 0,wall.post_id,CONCAT(wall.parentof,'.',wall.post_id )) AS neworder FROM wall INNER JOIN users ON wall.user_id = users.user_id ORDER BY neworder
I don't know whether I got the related keys right, but that's a way to go with two tables. The fact that you now have 3 tables should make it just as simple.