File size: 2.28Kb
<?php
include 'db.php';
include 'functions.php';
headtag("Notifications - $SiteName");
if($userlog==1){
$uid=dump_udata("id");
$act=formget("act");
$id=formget("id");
$user=dump_udata("username");
$hammad1=mysql_query("SELECT * FROM notifications WHERE user='$user'");
$khan1=mysql_fetch_array($hammad1);
echo '<div class="title">Notifications </div>';
if($act=="remove")
{
mysql_query('DELETE FROM notifications WHERE id="'.$id.'" AND user="'.$user.'"');
header('Location:/notifications.php');
}
else if($act=="removeall")
{
mysql_query('DELETE FROM notifications WHERE user="'.$user.'"');
header('Location:/notifications.php');
}
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
// how many rows to show per page
$rowsPerPage = 10;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$sql = " SELECT * FROM notifications WHERE user='".$user."' ORDER BY id DESC" .
" LIMIT $offset, $rowsPerPage ";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){ // Start looping table row
echo '<div class="ad"><b>'.$rows['news'].' <a href="?act=remove&id='.$rows['id'].'"><font align="right" color="red">[X]</font></a></b></div>';
}
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">Prev</a> || ";
$first = " <a href=\"$self?page=1\">First Page</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < 1000)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">Next</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
// print the navigation link
echo '<div class="ad"><b><a href="?act=removeall"><font align="right" color="red">[Clear All]</font></a></b></div>';
echo '<div class="notifications">'.$prev.' '.$nav.' '.$next.'</div>';
mysql_close();
echo '<div class="page"><a href="/user/dashboard">Go Back To Dashboard</a></div>';
//enf
}
else {
header('Location:/');
}
include 'foot.php';
?>