[eluser]Unknown[/eluser]
Hi folks!
I have a simple database structure like this:
Code:
entries table
+----+-----------+------------+-----------+------+
| id | date_time | post_title | post_slug | body |
+----+-----------+------------+-----------+------+
comments table
+----+-----------+----------+------+--------+
| id | date_time | entry_id | body | author |
+----+-----------+----------+------+--------+
I am in a situation where I need to loop through
all my etnries and
all the comments on the
same page. How do I go on and do this in the best possible way (performance and maintainability)
Do I need to first loop through all my entries and then within that loop get all it's comments and loop through them? That means alot of queries to the database. Is there a better way?
The desired output looks like this:
Code:
Entry #1
Comment #1
Comment #2
Entry #2
Comment #1
Comment #2
Comment #3
Entry #3
Entry #4
Comment #1
I hope this is not a duplicate of other posts but I searched for a long time and couldn't find anything...
Thanks!