Good day all. I'm working on a project involving listing all the asset a company has. The page (assetList.php) whose code I post below checks through the database and list all the assets when it loads. The pagination function is working fine and the default set of assets to be listed per page as you will see under function.php is 20. I want to a PRACTICAL EXAMPLE of what to do so that users/viewers can decide how many set per page they want to view by using a drop down menu which has options like 10, 20, 50, all. Thanks in advance. The codes now.

assetList.php

PHP Code:
<?php 

@session_start();
if(isset(
$_SESSION['userName'])) $_SESSION['userName'];

//connect to the database
    
include_once ('DatabaseManager.php'); 
    
$conn DatabaseManager::getConnection();
    
//get the function
    
include_once ('function.php');

        
$page = (int) (!isset($_GET["page"]) ? $_GET["page"]);
        
$limit 20;
        
$startpoint = ($page $limit) - $limit;
        
        
//to make pagination
        
$statement "`myasset`";


require_once 
'classes/Config.php';
 
$result = new ECConfig();
$result2 = new ECConfig();
$result3 = new ECConfig();
$result->getSiteName();
$result2->getSiteNickName();
$result3->getCurrency();
?>

<!DOCTYPE html>
<!--[if IE 8]>                  <html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->

<head>
    <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <title><?php echo $result->getSiteName(); ?>  | Asset Manager</title>
  <link href="../css/normalize.css" rel="stylesheet" />
  <link href="../css/foundation.css" rel="stylesheet" />
  <link href="../css/pagination.css" rel="stylesheet" type="text/css" />
  <link href="../css/B_blue.css" rel="stylesheet" type="text/css" />
  <link href="../main.css" rel="stylesheet" type="text/css" media="all">
  <script src="../js/vendor/custom.modernizr.js"></script>


</head>
<body>
<?php $query $conn->query("SELECT * FROM {$statement} ORDER BY id DESC LIMIT {$startpoint} , {$limit}"); ?>
<?php $assetRegister 
$conn->query("SELECT * FROM {$statement}"); 
      
$asset $assetRegister->rowCount(); ?>
     <div class="contain-to-grid">                    
                    <div class="top-bar text-center">
                    
                        <h3 class="dammy1"><?php echo $result->getSiteName(); ?></h3>
                        <h5 class="subheader"><?php echo $result->getSiteNickName(); ?></h5>
                    
    </div>
      </div>
      
 <!-- The part above takes care of the banner region -->
      
      <div class="row">
      <div class="breadcrumbs">
      <div class="large-7 columns">
        <a href="../homepage.php">Main Home</a> || <a href="index.php">Asset Manager Home</a> 
        </div>
        <div class="large-5 columns">
        You are logged in as <?php if(isset($_SESSION['userName'])) echo $_SESSION['userName']; ?> || <a href="index.php?action=logout" title="Log Out">Log Out <img src="../img/quit.png" alt="Log Out" /></a> 
        </div>
      </div> 
      </div>  
      
      <br/>   
      <div class="row">  
        <div class="large-9 columns">
        <?php include 'assetConsole.php'?>
        </div>
        
        <div class="large-3 columns">
        <?php include 'mainMenu.php'?>
        </div>
        
        </div><!--closing tag for the first row -->
        
        <div class="row">
        <div class="large-12 columns">
        <?php if(isset($query)): ?>
        <p class="searchResult">      
        <?php
          
if(isset($asset)) {
          
          if(
$asset == 0)
          {
               echo 
'There is no record of any asset in the database.';
          }
          if(
$asset == 1)
          {
              echo 
'There is 1 record of asset in the database.';
          }
          if(
$asset 1)
          {
              echo 
"There are $asset records of asset in the database.";
          }
          }
          
?>
          </p>
         <div class="large-4 columns panel"><h5>Asset Name</h5></div>
         <div class="large-3 columns panel"><h5>Cost Per Unit(In Figures)</h5></div>
         <div class="large-2 columns panel"><h5>Status</h5></div>
         <div class="large-3 columns panel"><h5>Action</h5></div>
                
         <?php foreach($query as $i=>$asset): ?>
                
                <div class="large-4 columns"><?php if(isset($asset['productName'])) echo ($asset['productName']); else echo 'Not Available'?></div>
                <div class="large-3 columns"><?php if(isset($asset['costPerUnitInFigures']))  echo ($asset['costPerUnitInFigures']); ?></div>
                <div class="large-2 columns"><?php if(isset($asset['status'])) echo ($asset['status']); ?></div>
                <div class="large-3 columns">
                 <form action="index.php" method="post">
                <div>
                  <input type="hidden" name="id" value="<?php  echo htmlentities($asset['id']); ?>"/>
                  <input type="submit" name="action" value="Edit" class="button myconsole2 radius" />
                  <input type="submit" name="action" value="Print PDF" class="button myconsole2 radius" />
                  <input type="submit" name="action" value="Delete" onclick="return confirm('Delete This Asset?')" class="button myconsole2 radius" />
                  
                </div>
              
              </form>
                </div>
             <hr/>
             <?php endforeach; ?>
          

        <?php endif; ?>
        <div class="large-12 columns paginate"><?php echo pagination($statement$limit$page); ?></div>
        
        </div>
        
     </div>
     
   
        
<br/>
<br/>
<br/>
<!-- Footer -->
<div class="wrapper row2">
  <div class="row">&nbsp;
  <br/>
   </div>
   </div> 
<div class="wrapper row4">
  <div class="row">
  <?php include 'mainFooter.php'?>
  </div>
</div>

</body>
</html>

function.php
PHP Code:
<?php

   
   
function pagination($query$per_page 10,$page 1$url '?'){ 
   include_once (
'DatabaseManager.php'); 
   
$conn DatabaseManager::getConnection();
           
        
$query "SELECT COUNT(*) as `num` FROM {$query}";
        foreach(
$conn->query($query) as $row);
        
$total $row['num'];
        
$adjacents "2"
        
        
//Ronald's code begings
        
$url '?';
        foreach(
$_GET as $k => $v) {
        if(
$k != 'page') {
        
$url .= "{$k}={$v}&";
          }
        }
        
//Ronald's code ends

        
$page = ($page == $page);  
        
$start = ($page 1) * $per_page;                                
        
        
$prev $page 1;                            
        
$next $page 1;
        
$lastpage ceil($total/$per_page);
        
$lpm1 $lastpage 1;
        
        
$pagination "";
        if(
$lastpage 1)
        {    
            
$pagination .= "<ul class='pagination'>";
                    
$pagination .= "<li class='details'>Page $page of $lastpage</li>";
            if (
$lastpage + ($adjacents 2))
            {    
                for (
$counter 1$counter <= $lastpage$counter++)
                {
                    if (
$counter == $page)
                        
$pagination.= "<li><a class='current'>$counter</a></li>";
                    else
                        
$pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                }
            }
            elseif(
$lastpage + ($adjacents 2))
            {
                if(
$page + ($adjacents 2))        
                {
                    for (
$counter 1$counter + ($adjacents 2); $counter++)
                    {
                        if (
$counter == $page)
                            
$pagination.= "<li><a class='current'>$counter</a></li>";
                        else
                            
$pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                    }
                    
$pagination.= "<li class='dot'>...</li>";
                    
$pagination.= "<li><a href='{$url}page=$lpm1'>$lpm1</a></li>";
                    
$pagination.= "<li><a href='{$url}page=$lastpage'>$lastpage</a></li>";        
                }
                elseif(
$lastpage - ($adjacents 2) > $page && $page > ($adjacents 2))
                {
                    
$pagination.= "<li><a href='{$url}page=1'>1</a></li>";
                    
$pagination.= "<li><a href='{$url}page=2'>2</a></li>";
                    
$pagination.= "<li class='dot'>...</li>";
                    for (
$counter $page $adjacents$counter <= $page $adjacents$counter++)
                    {
                        if (
$counter == $page)
                            
$pagination.= "<li><a class='current'>$counter</a></li>";
                        else
                            
$pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                    }
                    
$pagination.= "<li class='dot'>..</li>";
                    
$pagination.= "<li><a href='{$url}page=$lpm1'>$lpm1</a></li>";
                    
$pagination.= "<li><a href='{$url}page=$lastpage'>$lastpage</a></li>";        
                }
                else
                {
                    
$pagination.= "<li><a href='{$url}page=1'>1</a></li>";
                    
$pagination.= "<li><a href='{$url}page=2'>2</a></li>";
                    
$pagination.= "<li class='dot'>..</li>";
                    for (
$counter $lastpage - (+ ($adjacents 2)); $counter <= $lastpage$counter++)
                    {
                        if (
$counter == $page)
                            
$pagination.= "<li><a class='current'>$counter</a></li>";
                        else
                            
$pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                    }
                }
            }
            
            if (
$page $counter 1){ 
                
$pagination.= "<li><a href='{$url}page=$next'>Next</a></li>";
                
$pagination.= "<li><a href='{$url}page=$lastpage'>Last</a></li>";
            }else{
                
$pagination.= "<li><a class='current'>Next</a></li>";
                
$pagination.= "<li><a class='current'>Last</a></li>";
            }
            
$pagination.= "</ul>\n";        
        }
    
    
        return 
$pagination;
    } 
?>