Location: PHPKode > projects > Kwalbum > kwalbum/viewNews.php
<?php
// for Kwalbum 2.1.4
// by Tim Redmond

define('NEWS_POSTS_PER_PAGE', 15);

require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/include/DBConnection.php';
if (!isset($DB))
	$DB = new DBConnection();
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/include/verifyLogin.php';

if (isset($_GET['o']))
{
	if (($offset = (int)$_GET['o']) < 0)
		$offset = 0;
}
else
	$offset = 0;

$query = "
	SELECT ItemId, ItemDescription, ItemDate, ItemTime, ItemHasComments, UserId, UserTitle
	FROM ".ITEM_TABLE.", ".USER_TABLE."
	WHERE UserId=ItemUserIdFk AND ItemTypeId=255
	ORDER BY ItemDate DESC, ItemTime DESC
	LIMIT $offset,".NEWS_POSTS_PER_PAGE;
$result = $DB->Query($query);
if (0 == $result->num_rows)
{
	echo 'No news yet!';
	return;
}

while ($myrow = $result->fetch_array(MYSQLI_ASSOC))
{
	$date = date('M d, Y @ h:i A', strtotime($myrow['ItemDate'].' '.$myrow['ItemTime']));
	echo '<div class="pagecelltitle">'
	.'<span style="padding: 0px 10px 0px 10px; border-right: 1px solid;">'.$date.'</span>'
	.'<span style="padding: 10px;"><small>posted by</small> <b>'.$myrow['UserTitle'].'</b>'.($myrow['UserId'] == USER_ID ? ' <a href="'.PAGE_URL.'m=Edit&amp;i='.$myrow['ItemId'].'">[edit]</a>' : '').'</span></div>'
	.'<div class="pagecell">'.$myrow['ItemDescription']
	.'<div style="text-align: right"><a href="'.PAGE_URL.'i='.$myrow['ItemId'].'">'.($myrow['ItemHasComments'] ? 'View Comments' : 'Add the first comment.').'</a></div>'
	.'</div><br />';
}
$offset += NEWS_POSTS_PER_PAGE;
echo '<a href="index.php?o='.$offset.'">previous '.NEWS_POSTS_PER_PAGE.' posts</a>';
echo '<br /><br /><br />';

Return current item: Kwalbum