I have 2 tables one for articles and the other for comments
how can I fetch the comments of each article
now when I made fectching all comments show in the first article
I need to state every article with it's comments
plz I need code example also
I have 2 tables one for articles and the other for comments
how can I fetch the comments of each article
now when I made fectching all comments show in the first article
I need to state every article with it's comments
plz I need code example also
Within your articles table, make sure each one has a unique id. Then in your comments table make sure you have an article id field.
Every time a comment is submitted into the comments table make sure it is inserted with the article id field that is necessary to it.
Then on the PHP side of things. To display all the relevant comments for each article, at the bottom of the article's page have something like:
PHP Code:<?php
$query = mysql_query("SELECT * FROM comments WHERE `articleid` = '$tutid'");
while($row = mysql_fetch_array($query)){
echo $row['commentitle'] . "<br />" . $row['commentauthor'] . "<br />" . $row['comment'];
}
?>
Oooh I got the trick
I am trying it now
plz keep in touch to give you the result
No problem, just ask here again if you need anything else.
Yeah, you definitely should - I was just typing up a basic example of how to while loop out data from a database table.
It's also worth doing htmlentities sometimes for extra security against malicious code injections.
hi BBarash
everything is ok
my funny script work very good specially comments.
thx again and again
Bookmarks