Hey Everyone,
I previously had an issue with a date display format. I have a different question that deals with displaying singular or plural words using a version of an if statement that displays an "s" or displays nothing based on how many comments there are in a specific blog post. Here is the function that I've written and I'm afraid it may not be right. Any suggestions?
comments.inc.php
function gather_comments ($pid){
$pid = (int)$pid;
$sql = "SELECT * FROM `comments` WHERE `post_id`= {$pid}";
$comments = mysql_query($sql);
return $comments;
}
and here is blog_list.php
<h4 style="text-decoration: none;">(<?php echo $post['total_comments']; ?> comment<?php if(gather_comments() !=1){ echo '';}elseif(gather_comments == 0 || 1){echo 's';} ?>, last comment <?php echo $post['last_comment']; ?>)</h4>
basically, I want the word comment to be plural if there are either no or more than one comments in the database and if there are more than one comment in a database, to output the "s" and if there is either 1 to output nothing. This may seem simple to most but It would be very helpful to guide me in the right direction on how to handle this. Thanks in advance!