Location: PHPKode > projects > HB-NS > hb-ns/extra/latest_comments.php
<?php
//
// this file is an exmple of how to include a small sidebar which will list the last four comments
// with an extract of the text and a link to read more
//
// if you want to show more change the 4 in LIMIT 0,4 to another number
//
// include_once('../configuration.php');
// include_once('../functions.php');
// include_once('../lang/$language.php');


$query = "SELECT $comment_table.id as id, $comment_table.poster_name as poster_name, $comment_table.comment as comment FROM $comment_table LEFT JOIN $table USING (id) WHERE (expires >= '$now' OR expires = '00000000') AND push <= $now AND approved='1' ORDER BY $comment_table.uniqueid DESC LIMIT 0,4";
$result = mysql_query($query);
echo "<h4>Latest Comments</h4>\n";
while($query_data = mysql_fetch_array($result))
{
	$id3 = $query_data["id"];
	$poster_name3 = htmlentities($query_data["poster_name"]);
	$comment3 = strip_tags(convertBBCode($query_data["comment"]));
	$length = 50; // maximum amount of characters
	if (strlen($comment3) > $length) $comment3 = nl2br(ereg_replace("^(.{1,$length})[ .,].*", "\\1...", $comment3)); // echo the maximum amount of characters, but don't break words

	$query2 = "SELECT title FROM $table WHERE id = '$id3'";
	$result2 = mysql_query($query2);
	while($query_data = mysql_fetch_array($result2))
	{
		$title3 = htmlentities($query_data["title"]);
	}

	echo "<div class=\"sidebaritem\">$comment3<br />\n<strong>$poster_name3</strong> on <a href=\"$news_base" . "index.php?action=comment&amp;article=$id3#comments\" title=\"" . READ_MORE3 . " $title3\">$title3</a></div>\n";
}
?>
Return current item: HB-NS