Location: PHPKode > scripts > eoPaginator > example.php
<?php
require("eoPaginator.php");

$tmp_str="?total_recs=50&rpp=10&pagpp=5&pg_mode=1";

if (isset($_GET["cur_page"])) {$cur_page=$_GET["cur_page"];} else {$cur_page=1;}		/* Current page value */
if (isset($_GET["total_recs"])) {$total_recs=$_GET["total_recs"];} else {$total_recs=50;}	/* Total records(virtual) number */
if (isset($_GET["pg_mode"])) {$pg_mode=$_GET["pg_mode"];} else {$pg_mode=1;}			/* Pagination mode */
if (isset($_GET["rpp"])) {$rpp=$_GET["rpp"];} else {$rpp=10;}					/* Amount of records per page */
if (isset($_GET["pagpp"])) {$pagpp=$_GET["pagpp"];} else {$pagpp=5;} 				/* Amount of page thumbnails per page */


/* Composing dropdown list of available pagination modes */
$opt[0]="<option value=\"1\" _SEL_>Shift</option>";
$opt[1]="<option value=\"2\" _SEL_>Slide</option>";
$opt[2]="<option value=\"3\" _SEL_>Intersection</option>";

for ($i=0; $i<count($opt); $i++)
{
 if ($pg_mode==$i+1)
 {
  $opt[$i]=preg_replace("/_SEL_/","selected=\"selected\"", $opt[$i]);
 }
 else
 {
  $opt[$i]=preg_replace("/_SEL_/","", $opt[$i]);
 } 
}
$options=implode("", $opt);

/* Lets play with eoPaginator class */
$pag = new eoPaginator();
$pag->mode=$pg_mode;
$pag->rec_per_page=$rpp;
$pag->max_pages=$pagpp;

if ($_SERVER["QUERY_STRING"]<>"")
{
  if (strstr($_SERVER["QUERY_STRING"],"cur_page")!=false)
  {
    $pag->a_href="?".substr($_SERVER["QUERY_STRING"],0,strpos($_SERVER["QUERY_STRING"],"cur_page"))."cur_page=_PAGNUM_";
  } 
  else
  {
   $pag->a_href="?".$_SERVER["QUERY_STRING"]."&cur_page=_PAGNUM_";
  }
}
else 
{
 $pag->a_href = "?cur_page=_PAGNUM_";
}
$pag->a_class="pthumbs";
$pag->a_sel_class="pthumbs_cur";
$pag->sess_name="pag_test";

$pg=$pag->make_pgr($total_recs,$cur_page);
$pag_block=implode("",$pg);


echo "
<html>
<head>
<style type=\"text/css\">
.pthumbs {font-family:Verdana, Arial, Helvetica, Sans-serif; font-weight: normal;color: #2B60DE; padding: 1px; font-size: 10px; text-decoration:none;}
.pthumbs_cur {font-family:Verdana, Arial, Helvetica, Sans-serif; font-weight: normal; color: #2560DE; padding: 1px; background-color: #CCCCCC; border: 1px solid #2B60DE; font-size:11px; text-decoration:none;}
.pthumbs:hover{background-color: #CCCCCC; border: 1px solid #2B60DE; font-size:11px; color:#2560DE;}
.inp {border:1px solid #2B60DE; margin: 2px; font-family:Arial; font-size:12px;}
.lbl {font-family:Verdana, Arial, Helvetica, Sans-serif; font-weight: bold; font-size:10px; color: #2B60DE;}
</style>
</head>
<body>
<form id=\"pag_gen_frm\" method=\"get\">
<table style=\"border: 1px solid #CCCCCC; width:100%;\">
<tr>
 <td>
 <label class=\"lbl\">Total records:</label><input type=\"text\" name=\"total_recs\" size=\"2\" maxlength=\"3\" value=\"".$total_recs."\" class=\"inp\">
    <label class=\"lbl\">Records per page:</label><input type=\"text\" name=\"rpp\" size=\"2\" maxlength=\"2\" value=\"".$rpp."\" class=\"inp\">
    <label class=\"lbl\">Page tabs per page:</label><input type=\"text\" name=\"pagpp\" size=\"2\" maxlength=\"2\" value=\"".$pagpp."\" class=\"inp\">
    <label class=\"lbl\">Paginator mode:</label><select name=\"pg_mode\" class=\"inp\">". $options."</select><input type=\"submit\" value=\"Generate\" class=\"inp\">
    </td>
 <td style=\"border-left:1px solid #CCCCCC;\">".
    $pag_block    
 ."</td>
</tr>
<tr>
 <td colspan=\"2\" style=\"border-top:1px solid #CCCCCC; font-family:Verdana, Arial, Helvetica, Sans-serif;\">
  <label class=\"lbl\">Total pages:</label>".$pag->all_pages."<br />
  <label class=\"lbl\">Current page:</label>".$cur_page."<br />
  <label class=\"lbl\">SQL query limitation substring:</label>".$pag->query_limit."<br />
  </td>
</tr>
</table>
</form>
</body>
</html>";

?>
Return current item: eoPaginator