Jump to content

Simple pagination


mmarif4u

Recommended Posts

I have the below script, how to integrate a pagination to it,

Does any body have a good script

Thanks.

<?php
  
  //------------------------------------------------  
  $sort_enc = trim($_GET['sort_enc']);
  $tysort_enc = trim($_GET['tysort_enc']);
  if($sort_enc){
   $nmsort = decrypt_str($sort_enc);
   $tysort = decrypt_str($tysort_enc);
   $nmsort = "order by $nmsort $tysort";

   if($tysort=="asc"){
    $tysort_next = "desc";
   }else{
    $tysort_next = "asc";
   }
   $tysort_next_enc = encrypt_str($tysort_next);
  }else{
   $nmsort = "order by dtexam desc ";
  }

  $sql="select * from o_result where nruser=$session_nruser $nmsort "; // LIMIT $offset, $rowsPerPage";
  $result_list = db_select($sql);

  $sql="select tymodel,nmtymodel from t_tymodel where cdlangu=$session_cdlangu";
  $tymodel_arr = db_select_parameter($sql);

  $sql="select cdsubject,nmsubject from t_subject where cdlangu=$session_cdlangu";
  $subject_arr = db_select_parameter($sql);

  $sql="select cdlevel,nmlevel from t_level where cdlangu=$session_cdlangu";
  $level_arr = db_select_parameter($sql);
  //------------------------------------------------
  
  //-------------------------------------------------
  $query = "SELECT nrpackage FROM m_package where nrpackage='$session_nrpackage'";
$result = mysql_query($query) or die(mysql_error());
  //$ic=$row->$session_nrpackage;
if ($session_nrpackage == '1006') {
    
$disabled = "javascript:void(null);";
}//elseif ($session_nrpackage == '1001'){$disabled = "javascript:void(null);";} 
else{ $disabled1 = "style='display:none'";
}
?>

<br>
<br>
<table align="center" border="0" width="714" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><font class="txtbluev2_16"><b>PERFORMANCE REPORT</b> <br>
    <?php echo $session_nmname;?></font><br>
    <br>
    <font class="txtbluev2">Click the button next to the test date for report details.
    <br>
    To re-sort the list by Date, Subject, Set or Score, click the corresponding
    button.</font></td>
  </tr>
</table>
<br>
<script language="javascript">
function sort_report(sort,tysort){
var loc="<?php echo $_SERVER['PHP_SELF']; ?>";
if(loc){
   loc = loc + "?sort_enc="+ sort +"&tysort_enc=" + tysort;
   document.location = loc;
}
}
</script><table align="center" border="0" width="750" cellpadding="0" cellspacing="0"><tr align="left"><td <?php echo $disabled1?>><font color="red">
    <b>To see your report card upto three(complete) levels, please contact us for
    details.</td></tr></table>
<table align="center" border="1" style="border-collapse: collapse" width="750" cellspacing="0" cellpadding="0" bordercolor="#c0c0c0">
  <tr>
    <td height=30 align=center width=5% bgColor=#5168dd><font class=txtwhite>View</font></td>
    <td align=center width=12% bgColor=#5168dd><input onclick="sort_report('<?php echo encrypt_str("dtexam")."','".$tysort_next_enc; ?>')" type=button class=button_r2 value="  Date  "></td>
    <td align=center width=15% bgColor=#006699><input onclick="sort_report('<?php echo encrypt_str("tymodel")."','".$tysort_next_enc;?>')" type=button class=button_r1 value="Paper Type"></td>
    <td align=center width=11% bgColor=#5168dd><input onclick="sort_report('<?php echo encrypt_str("cdlevel")."','".$tysort_next_enc;?>')" type=button class=button_r2 value="Level"></td>
    <td align=center width=19% bgColor=#006699><input onclick="sort_report('<?php echo encrypt_str("cdsubject")."','".$tysort_next_enc;?>')" type=button class=button_r1 value="   Subject   "></td>
    <td align=center width=10% bgColor=#5168dd><input onclick="sort_report('<?php echo encrypt_str("nrset")."','".$tysort_next_enc;?>')" type=button class=button_r2 value="Set No"></td>
    <td align=center width=2% bgColor=#006699><input onclick="sort_report('<?php echo encrypt_str("nrtry")."','".$tysort_next_enc;?>')" type=button class=button_r1 value="Attempts"></td>
    <td align=center width=8% bgColor=#5168dd><input onclick="sort_report('<?php echo encrypt_str("tmtime")."','".$tysort_next_enc;?>')" type=button class=button_r2 value="Time"></td>
    <td align=center width=12% bgColor=#006699><input onclick="sort_report('<?php echo encrypt_str("nrtotscorepc")."','".$tysort_next_enc;?>')" type=button class=button_r1 value="Score,%"></td>
  </tr>
  <?php
   while($row = db_fetch_object($result_list)){
     $tymodel = $row->tymodel;
     $nmtymodel = $tymodel_arr[$row->tymodel];
     $nmsubject = $subject_arr[$row->cdsubject];
     $nmlevel = $level_arr[$row->cdlevel];
     $nrtotscorepc = $row->nrtotscorepc;
     $nrtotscorepc = round($nrtotscorepc*10)/10;
     $txscore = set_score_color($nrtotscorepc);
     $txstart = convert_date_text($row->dtstart);
     $nrtry =$row->nrtry;
     $tmtime =$row->tmtime;
     $nrset =$row->nrset;
     $nrresult =$row->nrresult;
     $nrresult_enc =encrypt_str($nrresult);

     $tmtime = round($tmtime/60);
     if($tymodel ==3){
      $txset = $row->nryear;
     }else{
      $txset = $nrset;
     }
     if($txset ==0){
      $txset = "";
     }

  ?>
  <tr>
    <td align=center bgColor=#C0C0C0><a href="<?php echo $disabled ?><?php echo "std_report_dtl.php?nrresult_enc=$nrresult_enc";?>" ><img src="images/view.jpg" border=0></a></td>
    <td align=center><?php echo $txstart; ?></td>
    <td align=center><?php echo $nmtymodel; ?></td>
    <td align=center><?php echo $nmlevel; ?></td>
    <td align=center><?php echo $nmsubject; ?></td>
    <td align=center><?php echo $txset; ?></td>
    <td align=center><?php echo $nrtry; ?></td>
    <td align=center><?php echo $tmtime." m"; ?></td>
    <td align=center><?php echo $txscore; ?></td>
  </tr>
  <?php
   }
  ?>
</table>

Link to comment
https://forums.phpfreaks.com/topic/41751-simple-pagination/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.