I'm a bit of a novice to PHP and MySQL. I'm creating my own little news blog for the heck of it. I got to display the information I wanted, but what I want to do is count the number of comments. I made 2 tables, the first table is the article and the other is the comments. I not to sure of how to figure this out. Can anyone help?
$input_now1 = "SELECT blog_entries.id, blog_entries.posted, blog_entries.subject, blog_entries.quicktext
FROM blog_entries
ORDER BY blog_entries.posted DESC
LIMIT 0, 3;";
$result1 = mysql_query($input_now1);
?>
<div id="middle">
<div id="box1">
<?php
while($record1 = mysql_fetch_assoc($result1))
{
?>
<h2 style="padding-top:5px;"><?php echo $record1['subject']; ?></h2>
<div id="header1" style="position:relative;"></div>
<div id="maintext" style="position:relative;">
<p><?php echo $record1['quicktext']; ?></p>
<a href="blog_articles.php?ID=<?php echo $record1["id"];?>">View Article - <?php echo date("D jS F Y g:iA",strtotime($record1["posted"]));?></a>
</div>
<div id="text_footer"></div>
<?php
}
mysql_free_result($result1);
?>
</div>
<?php
include 'include/sidebar.php';
?>
</div>
Table1 blog_entries: id posted subject body quicktext
Table2 blog_comments: id blog_id posted name comment