<?php
session_start();
$x=0;
$empID = $_SESSION['id'];
include("connect.php");
//Obtain the required page number
if (isset($_GET['pageno']))
{
$pageno = $_GET['pageno'];
}
else
{
$pageno = 1;
} // if
//Identify how many database rows are available
$query = "SELECT count(*) FROM tbl_absence";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
//Calculate number of $lastpage
$rows_per_page = 10;
$lastpage = ceil($numrows/$rows_per_page);
//Ensure that $pageno is within range
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
$pageno = $lastpage;
} // if
if ($pageno < 1) {
$pageno = 1;
} // if
//Construct LIMIT clause
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
//Issue the database query
$query = "SELECT * FROM tbl_absence where empID='$empID' ORDER BY absID DESC $limit";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
$rs = mysql_query($query) or die("Invalid Query <br>$sql");
$count=mysql_num_rows($rs);
if($count==0)
{
echo'<br/><center><font style="font-family:Tahoma;font-size:11px;color:#990000"> No Leave of Absence in your Inbox</font></center><br/>';
}
while($row = mysql_fetch_array($result))
{
$user_read=$row['user_read'];
$reply_date=$row['reply_date'];
echo'<form name="form1" method="post" action="">';
if($user_read=='y' and $reply_date!='')
{
echo'<table>';
echo'<tr>';
echo'<td width="6"> </td>';
echo'<td width="60" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['absID'].'"> </td>';
echo'<td width="160"><font face="Tahoma" size="1" color="black"><b><a href="absent_repcont.php?id='.$row['absID'].'"><b>'.$row['subject'].'</b></a></font></td>';
echo'<td width="116"><font face="Tahoma" size="1" color="black"><b>'.$row['n_leave'].'</font></b></td>';
echo'<td width="120"><font face="Tahoma" size="1" color="black"><b>'.' '.''.$row['act'].'</font></b></td>';
echo'<td width="116"><font face="Tahoma" size="1" color="black"><b> '.$row['reply_date'].'</font></b></td>';
echo'</tr>';
echo'</table>';
echo'<hr align="center" width="100%"></hr>';
}
elseif($user_read=='n' and $reply_date!='')
{
echo'<table>';
echo'<tr>';
echo'<td width="6"> </td>';
echo'<td width="60" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['absID'].'"> </td>';
echo'<td width="160"><font face="Tahoma" size="1" color="black"><a href="absent_repcont.php?id='.$row['absID'].'">'.$row['subject'].'</a></font></td>';
echo'<td width="116"><font face="Tahoma" size="1" color="black">'.$row['n_leave'].'</font></b></td>';
echo'<td width="120"><font face="Tahoma" size="1" color="black">'.' '.''.$row['act'].'</font></td>';
echo'<td width="116"><font face="Tahoma" size="1" color="black" '.$row['reply_date'].'</font></td>';
echo'</tr>';
echo'</table>';
echo'<hr align="center" width="100%"></hr>';
}
}
echo'<br/>';
//Construct pagination hyperlinks
if ($pageno == 1) {
echo " ";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'><img border='0' src='images/start.jpg' height='25' width='25'/></a> ";
$prevpage = $pageno-1;
echo "<a href='{$_SERVER["PHP_SELF"]}?pageno=$prevpage'><img border='0' src='images/arrow_left.jpg' height='25' width='25'/></a>";
} // if
echo " ( Page $pageno of $lastpage ) ";
if ($pageno == $lastpage) {
echo "";
} else {
$nextpage = $pageno+1;
echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'><img border='0' src='images/arrow_right.jpg' height='25' width='25'/></a>" ;
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'><img border='0' src='images/end.jpg' height='25' width='25'/></a>";
} // if
?>
No comments:
Post a Comment