Page 1 of 1

problem in managing pages !

Posted: Mon Feb 21, 2005 5:48 am
by itsmani1
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 --------------------------------------------

Code: Select all

<?php 
   class Pager 
   &#123; 
       function getPagerData($numHits, $limit, $page) 
       &#123; 
           $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; 
       &#125; 
   &#125; 
?>
--------------------------- view report.php -------------------------

Code: Select all

<?php
 $page=$_REQUEST&#1111;"page"];
  $limit =10;
  $qry = "SELECT * FROM tbl_app"; 
  $res = mysql_db_query($db,$qry,$cid);
  $cnt = mysql_num_rows($res);
  if( (!isset($_POST&#1111;'regional'])) and (!isset($_POST&#1111;'discipline'])) and (!isset($_POST&#1111;'university'])) )&#123;
  echo "Make selection to see Reports";
  exit;
  &#125;

  $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&#1111;'regional']))&#123;
$regional = $_POST&#1111;'regional'];

&#125;
$discipline = 0;
if(isset($_POST&#1111;'discipline']))&#123;
$discipline = $_POST&#1111;'discipline'];

&#125;
$university = 0;
if(isset($_POST&#1111;'university']))&#123;
$university = $_POST&#1111;'university'];

&#125;
if($regional != 0)&#123;
	$strqr .= " a.region = $regional and ";
	&#125;
if($discipline != 0)&#123;
	$strqr .= " c.disciplineid = $discipline and ";
	&#125;
if($university != 0)&#123;
	$strqr .= " c.universityid = $university and ";
	&#125;
  if(isset($_GET&#1111;'from'])):
   $Rdat = $_GET&#1111;'from'];
  else:
   if(isset($_POST&#1111;'month'])):
	$month=$_POST&#1111;"month"];
   else:
	$month=1;
   endif;
   if(isset($_POST&#1111;'day'])):
	$day=$_POST&#1111;"day"];
   else:
	$day=1;
   endif;
   if(isset($_POST&#1111;'year'])):
	$year=$_POST&#1111;"year"];
   else:
	$year=1996;
   endif;
   $datef = $day."/".$month."/".$year;
   $Rdat = $year."/".$month."/".$day;
  endif;
  $today = getdate();
  if(isset($_GET&#1111;'to'])):
   $Rdatto = $_GET&#1111;'to'];
  else:
   if(isset($_POST&#1111;'monthto'])):
	$monthto=$_POST&#1111;"monthto"];
   else:
	$monthto=date("m",time()); 
   endif;
   if(isset($_POST&#1111;'dayto'])):
	$dayto=$_POST&#1111;"dayto"];
   else:
	$dayto=$today&#1111;'mday'];
   endif;
   if(isset($_POST&#1111;'yearto'])):
	$yearto=$_POST&#1111;"yearto"];
   else:
	$yearto=$today&#1111;'year'];
   endif;
   $Rdatto = $yearto."/".$monthto."/".$dayto;
   $datet = $dayto."/".$monthto."/".$yearto;
  endif;

if(($discipline == 0 ) && ($university == 0) && ($regional == 0))&#123;
    $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 ";
&#125;
if(($discipline != 0) && ($university == 0) && ($regional == 0))&#123;
    $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 ";
&#125;

if(($discipline == 0) && ($university != 0) && ($regional == 0))&#123;
    $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 ";
&#125;

if(($discipline == 0) && ($university == 0) && ($regional != 0))&#123;
    $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 ";
&#125;
$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&#1111;"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)&#123;
				  ?>
  <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)) &#123;
			  		  $Rid =stripslashes($rowReport->appid);

//					  $regnum=stripslashes($row&#1111;"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="&nbsp;";
					  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&#1111;'PHP_SELF']?>?PgAction=EditReport&Section=Report&ShowReport=<?=$Rid?>">
      <?=$Rapp?>
      </a></td>
    <td class="TableTxt"><div align="center"><a href="<?=$_SERVER&#1111;'PHP_SELF']?>?PgAction=EditReport&Section=Report&ShowReport=<?=$Rid?>"> 
        </a> 
        <?=$resume?>
      </div></td>
    <td class="TableTxt" align="center" valign="middle"><?=$Rapp1?></td>
  </tr>
  <?
			  	      $rowReport_count++;
				    &#125;
?>
  <tr bgcolor="#EAEAEA"> 
    <td class="TableTxt" colspan="4">Displaying Page <? echo $page; ?> of Total 
      <? echo $totalpages; ?> Pages<br>
      Pages: 
      <?
              if ($page != 1)
			    &#123;
                  echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=" . ($page - 1) . ""> Previous </a>";
				 &#125;
			    for ($i = $page; $i <=($page+5); $i++) &#123;
                  if ($i <= $totalpages) &#123;
                      if ($i != 1 )
    				      echo " | ";
				  if ($i == $pager->page)
                    echo "$i";
                    else
                     echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=$i"> $i</a>";

				   &#125;
                    &#125;

			   if ($page != $totalpages)
			   &#123;
                 echo " | ";
				 echo "<a href="adminhome.php?PgAction=ViewReport&Section=Report&page=" . ($page + 1) . ""> Next </a>";
				&#125;
				

             ?>
    </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")); 

				  &#125;else&#123;
		  		  ?>
  <tr> 
    <td colspan=5 align="center" class="TableTxt">< There are no Reports ></td>
  </tr>
  <?
  &#125;
  ?>
</table>

Posted: Thu Feb 24, 2005 2:01 am
by smpdawg
What ever became of this? Has the problem been solved? Do you have a test area where this script can be seen?