news and comments
Posted: Mon Aug 18, 2003 1:24 am
i'm making my home page, which has the news. and i want to add a comments system. i know how to write a comments system and a news system but having a hard time merging them togeather.
like the news are posted from my control panel i wrote. it inserts TITLE and NEWS into my sql db. then in the index.php, it reads from the db.
now i want to add the No. of comments on the news. how would i do it? here what's i'm guessing. i've not tried it yet though:
thanks...
-Nay
like the news are posted from my control panel i wrote. it inserts TITLE and NEWS into my sql db. then in the index.php, it reads from the db.
now i want to add the No. of comments on the news. how would i do it? here what's i'm guessing. i've not tried it yet though:
Code: Select all
<?
$connection = mysql_connect("$hostname" , "$user" , "$pass");
$db = mysql_select_db($dbase , $connection);
$q="SELECT * from news order by id desc limit 5";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) {
$title=$row["title"];
$news=$row["news"];
$q="SELECT * from comments where commentfrom=$title";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
$noOfComments = mysql_num_rows($result);
echo "$title<br>";
echo "$news<br>";
echo :Comments: $noOfComments";
}
?>-Nay