problem in managing pages !
Posted: Mon Feb 21, 2005 5:48 am
hi there....
here is some code tht is showinf reports
i hav problem in managing pages :
this is the result tht mypage is showing(Pages: 1 | 2 | 3 | Next ) which is ok but problem is tht when i click on next it donot show any thing
and on page the results are ok
plz. see and help if u can .....
---------------------- pager.php --------------------------------------------
--------------------------- view report.php -------------------------
here is some code tht is showinf reports
i hav problem in managing pages :
this is the result tht mypage is showing(Pages: 1 | 2 | 3 | Next ) which is ok but problem is tht when i click on next it donot show any thing
and on page the results are ok
plz. see and help if u can .....
---------------------- pager.php --------------------------------------------
Code: Select all
<?php
class Pager
{
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
?>Code: Select all
<?php
$page=$_REQUESTї"page"];
$limit =10;
$qry = "SELECT * FROM tbl_app";
$res = mysql_db_query($db,$qry,$cid);
$cnt = mysql_num_rows($res);
if( (!isset($_POSTї'regional'])) and (!isset($_POSTї'discipline'])) and (!isset($_POSTї'university'])) ){
echo "Make selection to see Reports";
exit;
}
$rowReport_count=0;
$strqr = "select
a.appid, a.appdate, a.surname, a.flag, a.title, a.forename, a.status, a.regnum
from
tbl_app a,
tbl_course c,
tbl_app_course ac
where
a.appid = ac.appid and
c.courseid = ac.courseid and ";
$regional = 0;
if(isset($_POSTї'regional'])){
$regional = $_POSTї'regional'];
}
$discipline = 0;
if(isset($_POSTї'discipline'])){
$discipline = $_POSTї'discipline'];
}
$university = 0;
if(isset($_POSTї'university'])){
$university = $_POSTї'university'];
}
if($regional != 0){
$strqr .= " a.region = $regional and ";
}
if($discipline != 0){
$strqr .= " c.disciplineid = $discipline and ";
}
if($university != 0){
$strqr .= " c.universityid = $university and ";
}
if(isset($_GETї'from'])):
$Rdat = $_GETї'from'];
else:
if(isset($_POSTї'month'])):
$month=$_POSTї"month"];
else:
$month=1;
endif;
if(isset($_POSTї'day'])):
$day=$_POSTї"day"];
else:
$day=1;
endif;
if(isset($_POSTї'year'])):
$year=$_POSTї"year"];
else:
$year=1996;
endif;
$datef = $day."/".$month."/".$year;
$Rdat = $year."/".$month."/".$day;
endif;
$today = getdate();
if(isset($_GETї'to'])):
$Rdatto = $_GETї'to'];
else:
if(isset($_POSTї'monthto'])):
$monthto=$_POSTї"monthto"];
else:
$monthto=date("m",time());
endif;
if(isset($_POSTї'dayto'])):
$dayto=$_POSTї"dayto"];
else:
$dayto=$todayї'mday'];
endif;
if(isset($_POSTї'yearto'])):
$yearto=$_POSTї"yearto"];
else:
$yearto=$todayї'year'];
endif;
$Rdatto = $yearto."/".$monthto."/".$dayto;
$datet = $dayto."/".$monthto."/".$yearto;
endif;
if(($discipline == 0 ) && ($university == 0) && ($regional == 0)){
$strqr = "select
a.appid,
a.title,
a.surname,
a.flag,
a.surname,
a.forename,
a.appdate,
a.status,
a.regnum
from
tbl_app a
where ";
}
if(($discipline != 0) && ($university == 0) && ($regional == 0)){
$strqr="select
a.appid,
a.title,
a.surname,
a.flag,
a.surname,
a.forename,
a.appdate,
a.status,
a.regnum
from
tbl_app a
where
a.region = $discipline and ";
}
if(($discipline == 0) && ($university != 0) && ($regional == 0)){
$strqr="select
a.appid,
a.title,
a.surname,
a.flag,
a.surname,
a.forename,
a.appdate,
a.status,
a.regnum
from
tbl_app a,
tbl_app_course ac,
tbl_course c
where
a.appid = ac.appid and
ac.courseid = c.courseid and
c.universityid = $university and ";
}
if(($discipline == 0) && ($university == 0) && ($regional != 0)){
$strqr="select
a.appid,
a.title,
a.surname,
a.flag,
a.surname,
a.forename,
a.appdate,
a.status,
a.regnum
from
tbl_app a
where
a.region = $regional and ";
}
$strqr.=" a.appdate between '$Rdat' and '$Rdatto' order by a.appdate";
$temp = $strqr;
$re = mysql_query($temp);
$nu = mysql_num_rows($re);
$pager = Pager::getPagerData($nu, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
$totalpages= $pager->numPages;
$strqr.=" DESC LIMIT $offset, $limit";
$resReport = mysql_db_query($db,$strqr,$cid) or die(mysql_error());
$cntReport = mysql_num_rows($resReport);
// echo $cntReport;exit;
if($regional == 0):
$RName = "All regions";
else:
$result=mysql_query("SELECT Rname FROM tbl_region WHERE regionID='".$regional."'");
if(!mysql_num_rows($result)):
$RName = "Unknown region";
else:
$row=mysql_fetch_array($result);
$RName = stripslashes($rowї"Rname"]);
endif;
endif;
?>
<span class="ContentHdr">View Reports (Region:
<?=$RName?>
;Dates from <?=$datef?>
to
<?=$datet?>
)</span><br>
<table cellspacing=2 cellpadding=4 border=0 width="90%" align="left">
<?
if($cntReport > 0){
?>
<tr>
<td width="8%" class="ColumnHdr" bgcolor="#556FB1"><b>Reg#</b></td>
<td width="14%" class="ColumnHdr" bgcolor="#556FB1"><b>Date</b></td>
<td width="41%" class="ColumnHdr" bgcolor="#556FB1"><b>Applicant</b></td>
<td width="11%" class="ColumnHdr" bgcolor="#556FB1"><strong>Enq/App</strong></td>
<td width="26%" class="ColumnHdr" bgcolor="#556FB1" align="center"><strong>Status</strong></td>
</tr>
<?
$bgColor="DBE5FF";
while ($rowReport = mysql_fetch_object($resReport)) {
$Rid =stripslashes($rowReport->appid);
// $regnum=stripslashes($rowї"regnum"]);
$regnum=stripslashes($rowReport->regnum);
$Rdate =stripslashes($rowReport->appdate);
$Rapp1 = stripslashes($rowReport->status);
$Rapp = stripslashes($rowReport->title)." ".stripslashes($rowReport->forename)." ".stripslashes($rowReport->surname);
$bgColor=($bgColor=="DBE5FF")?("FFFFFF"):("DBE5FF");
$resume=" ";
switch($rowReport->flag):
case 1: $resume="<img src=images/flag.jpg border=0>"; break;
case 0: $resume=""; break;
endswitch;
?>
<tr bgcolor="#<?=$bgColor?>">
<td class="TableTxt">
<?=$regnum?>
</td>
<?PHP
$y = substr($Rdate,0,-6);
$m = substr($Rdate,4,-3);
$d = substr($Rdate,8);
$date = $d.$m."-".$y;
?>
<td class="TableTxt"><? echo $date;// echo $d.$m."-".$y; ?> </td>
<td class="TableTxt"><a href="<?=$_SERVERї'PHP_SELF']?>?PgAction=EditReport&Section=Report&ShowReport=<?=$Rid?>">
<?=$Rapp?>
</a></td>
<td class="TableTxt"><div align="center"><a href="<?=$_SERVERї'PHP_SELF']?>?PgAction=EditReport&Section=Report&ShowReport=<?=$Rid?>">
</a>
<?=$resume?>
</div></td>
<td class="TableTxt" align="center" valign="middle"><?=$Rapp1?></td>
</tr>
<?
$rowReport_count++;
}
?>
<tr bgcolor="#EAEAEA">
<td class="TableTxt" colspan="4">Displaying Page <? echo $page; ?> of Total
<? echo $totalpages; ?> Pages<br>
Pages:
<?
if ($page != 1)
{
echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=" . ($page - 1) . ""> Previous </a>";
}
for ($i = $page; $i <=($page+5); $i++) {
if ($i <= $totalpages) {
if ($i != 1 )
echo " | ";
if ($i == $pager->page)
echo "$i";
else
echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=$i"> $i</a>";
}
}
if ($page != $totalpages)
{
echo " | ";
echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=" . ($page + 1) . ""> Next </a>";
}
?>
</td>
<td>
<?PHP
$temp = stripslashes ($temp);
echo "<a href="createadminrep1.php?Pgs=$temp&des=admin"><div align="center"><img src="images/excel.jpg" width="32" height="32" border="0"></a>"; ?>
<div align="center"></div>
<div align="center"></div></td>
</tr>
<?
$session_demo->set_var("page",getenv("HTTP_REFERER"));
}else{
?>
<tr>
<td colspan=5 align="center" class="TableTxt">< There are no Reports ></td>
</tr>
<?
}
?>
</table>