Re: [Illume Magazine] Comments Compare + Count
Hi,
You can get a count of the number of comments a particular article has during the foreach loop that is listing the articles.
The code you use would look something like this:
<?php foreach($articleRecords as $article): ?>
<?php
$commentValue = "/zine/articleDetail.php?".str_replace("'","-",str_replace(" ","-",$article['title']))."-".$article['num'];
$count = mysql_select_count_from("comments","commentValue='$commentValue'");
?>
.
.
** NORMAL OUTPUT **
.
.
<?php endforeach ?>
What this code does is, for each article you selected, construct what the commentValue for that article would look like IF that article had comments. It then uses the function mysql_select_count_from() to get a count of comments in the comments table that have that commentValue and store that number in the variable $count (note: if there are no comments in the comments table for that article, it will return the number 0).
You can then output the $count variable where ever you want to display the number of comments that article has.
You may need to change some names to match what's in your database, etc.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/