I would like to know how I could make a commenting system so below each entry, there will be a link that says X Comment(s), where X is the number of comments for that entry. And I want that link to go to a page where you can leave comments for just that entry. I think maybe having a field in the comments table called newsid or something would be what I need to identify which news post the comments go to, that way when you click the X Comments link at the bottom of an entry, it only shows that entry's comments. So, maybe someone can show me a tutorial somewhere or post what the code should look like. And here's the code for my news page in case it's needed to analyze:
Code: Select all
<p align="center" class="header1">News</p>
<form method="post" action="?z=news.php">
<select name="month" class=inputbox>
<option value="01.">January</option>
<option value="02.">February</option>
<option value="03.">March</option>
<option value="04.">April</option>
<option value="05.">May</option>
<option value="06.">June</option>
<option value="07.">July</option>
<option value="08.">August</option>
<option value="09.">September</option>
<option value="10.">October</option>
<option value="11.">November</option>
<option value="12.">December</option>
</select>
<select name="year" class=inputbox>
<option value=".03">2003</option>
<option value=".02">2002</option>
</select>
<input type="submit" class=button value="Go">
</form>
<?
include("news/connect.php");
if ($month == '') {
?>
<?
$curmonth = "" . date("m", time() -10800) . ".";
$curyear = "." . date("y", time() -10800) . "";
$result = mysql_query ("SELECT * FROM news WHERE Date LIKE '%$curmonth%' '%$curyear%' ORDER BY id DESC");
while($r=mysql_fetch_array($result))
{
$Entry=stripslashes($r["Entry"]);
$ID=stripslashes($r["ID"]);
$Title=stripslashes($r["Title"]);
$Name=stripslashes($r["Name"]);
$Date=stripslashes($r["Date"]);
$Time=stripslashes($r["Time"]);
$Email=stripslashes($r["Email"]);
echo "<table width=435 cellpadding=0 cellspacing=0 class=blanktable><tr class=blanktable><td><a name=$ID></a><span class='header2'>$Title</span> by <a href='mailto:$Email'>$Name</a> on <span class='dates'>$Date</span> at <span class='dates'>$Time</span><br>" . nl2br($Entry) . "</td></tr><tr class=blanktable><td height=45 background='images/newsbottom.gif' class=blanktable></td></tr></table><br>";
}
?>
<?
} else {
?>
<?
$result = mysql_query ("SELECT * FROM news WHERE Date LIKE '%$month%' '%$year%' ORDER BY id DESC");
while($r=mysql_fetch_array($result))
{
$Entry=stripslashes($r["Entry"]);
$Title=stripslashes($r["Title"]);
$Name=stripslashes($r["Name"]);
$Date=stripslashes($r["Date"]);
$Time=stripslashes($r["Time"]);
$Email=stripslashes($r["Email"]);
echo "<table width=435 cellpadding=0 cellspacing=0 class=blanktable><tr class=blanktable><td><a name=$ID></a><span class='header2'>$Title</span> by <a href='mailto:$Email'>$Name</a> on <span class='dates'>$Date</span> at <span class='dates'>$Time</span><br>" . nl2br($Entry) . "</td></tr><tr class=blanktable><td height=45 background='images/newsbottom.gif' class=blanktable></td></tr></table><br>";
}
?>
<?
}
?>