10.6. Displaying Comments for a Given Entry
With retrieveComments() functional, you can now display the entries loaded when a user views an entry on the blog.
You can do this by creating a new showComments() method that accepts the blog ID as an argument ($blog_id). This method begins by initializing an empty variable ($display) to contain the formatted comments, then calls the retrieveComments() method to get the entry's comments loaded into memory.
With the comments loaded into $display, you can loop through each comment and create HTML markup to display them. Inside the loop, you want to check whether retrieveComments() has returned the default value, which means no comments exist for the entry. To do this, you set up a conditional statement ...
Get PHP for Absolute Beginners now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.