Posts: 3
Threads: 1
Joined: Jul 2011
Is there a way to pull the comments from the DB in to a separate section of the site. as the user post a comment on the site in any section the recent comment section gets up dated and where or what they comments on ? i am never to php is there anyone that can help ,me?
therealdaveharevy
Posts: 2,904
Threads: 59
Joined: Jun 2010
Hi,
You could experiment with this. You will need to replace "localhost", "mysql_user", "mysql_password" and "database" with the correct values.
PHP Code:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM comments WHERE is_approved = '1' ORDER BY dated DESC LIMIT 5", $link);
while ($comments = mysql_fetch_assoc($result)) {
echo $comments["comment"];
echo "<p />";
}
?>
Have
you completed
the interview?