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

$query = "SELECT id, text, title FROM $table WHERE (expires >= '$now' OR expires = '00000000') AND push <= $now ORDER BY id DESC LIMIT 0,3";
$result = mysql_query($query);
echo "<h4>Latest Headlines</h4>\n";
while($query_data = mysql_fetch_array($result))
{
	$id2 = $query_data["id"];
	$title = htmlentities($query_data["title"]);
	$text = strip_tags(convertBBCode($query_data["text"]));
	$length = 50; // maximum amount of characters
	if (strlen($text) > $length) $text = ereg_replace("^(.{1,$length})[ .,].*", "\\1...", $text); // echo the maximum amount of characters, but don't break words
	echo "<div class=\"sidebaritem\"><strong>$title</strong><br />\n$text<br />\n";
	echo "<a href=\"$news_base" . "index.php?article=$id2\" title=\"" . READ_MORE3 . " $title\">" . READ_MORE2 . " &gt;&gt;&gt;</a></div>\n";
}
?>
Return current item: HB-NS