Pagination records per page in select option
<p>I am creating a dynamic table and I want to have custom select option for the Records per Page. I look on a site but it doesn't have select option for pages</p>

<p>My idea is like this:</p>

<p>I want to change the <strong><code>$per_page</code></strong> to a PHP tag but it gives me an error if i use <code>$_GET</code> and <code>$_POST</code>.. thanks for the help</p>

<pre><code>&lt;form method="GET"&gt;
 &lt;select id="records" name="records"&gt; 
            &lt;option value="10"&gt;10&lt;/option&gt;
                &lt;option value="20"&gt;20&lt;/option&gt;
            &lt;option  value="30"&gt;30&lt;/option&gt;
            &lt;option  value="40"&gt;Mostra tutti&lt;/option&gt;
            &lt;/select&gt;&lt;li&gt;
            &lt;li&gt;&lt;input type = "submit" class = button2 name = "btnsubmit"&gt;&lt;/li&gt;
            &lt;/form&gt;
 &lt;/ul&gt;&lt;/nav&gt; 

&lt;?php
$page_name="admin_list.php";
$per_page = 10 ;

      if ($result = $con-&gt;query("SELECT * FROM clienti  WHERE utenza =1  OR utenza =0 ORDER BY es_insegna_esercizio"))
      {

      if ($result-&gt;num_rows != 0)
      {
      $total_results = $result-&gt;num_rows;
      // ceil() returns the next highest integer value by rounding up value if necessary

      $total_pages = ceil($total_results / $per_page);

      // check if the 'page' variable is set in the URL (ex: view-paginated.php?page=1)
      if (isset($_GET['page']) &amp;&amp; is_numeric($_GET['page']))
      {
      $show_page = $_GET['page'];

      // make sure the $show_page value is valid
      if ($show_page &gt; 0 &amp;&amp; $show_page &lt;= $total_pages)
      {
      $start = ($show_page -1) * $per_page;
      $end = $start + $per_page;
      }
      else
      {
      // error - show first set of results
      $start = 0;
      $end = $per_page;
      }
      }
      else
      {
      // if page isn't set, show first set of results
      $start = 0;
      $end = $per_page;
      }

      echo "&lt;table id='my_table' class='tables' name ='tablename'&gt;";

          echo "

          &lt;thead&gt;&lt;tr&gt;
                    &lt;th&gt;&lt;/th&gt;
                    &lt;th&gt;
                &lt;input type = checkbox &gt;
                    &lt;/th&gt;
                    &lt;th&gt;Azienda&lt;/th&gt;
                     &lt;th&gt;Utente&lt;/th&gt;
                     &lt;th&gt;Cognome&lt;/th&gt;

          &lt;/tr&gt;&lt;/thead&gt;
              " ;

          // loop through results of database query, displaying them in the table
          for ($i = $start; $i &lt; $end; $i++){
          // make sure that PHP doesn't try to show results that don't exist
          if ($i == $total_results) { break; }
          // find specific row
          $result-&gt;data_seek($i);
          $row = $result-&gt;fetch_row();
          // echo out the contents of each row into a table
          echo "&lt;tr&gt;";

              echo '&lt;td&gt;&lt;img src ="images/edit_icon.png"class = "autoResizeImage" onclick="JavaScript:newPopup(\'admin_edit.php?id='.$row['0'].'\')" /&gt;&lt;/td&gt;';
              echo '&lt;td&gt;&lt;input type=checkbox name=chk[] class= chk-box value='.$row[0].'/&gt;&lt;/td&gt;';
              echo '&lt;td&gt;' . $row[14] . '&lt;/td&gt;';
              echo '&lt;td&gt;' . $row[2]. '&lt;/td&gt;';
              echo '&lt;td&gt;' . $row[3] . '&lt;/td&gt;';
              echo '&lt;td&gt;' . $row[4] . '&lt;/td&gt;';

              echo "&lt;/tr&gt;";
          }
          // close table&gt;
          echo "&lt;/table&gt;&lt;/form&gt;";  
      }
      else{
      echo "No results to display!";
      }
      }
      // error with the query
      else{
      echo "Error: " . $con-&gt;error;
      }
    echo "&lt;p&gt; 
 &lt;b&gt;View Page: &lt;/b&gt;";
    for ($i = 1; $i &lt;= $total_pages; $i++){
    if (isset($_GET['page']) &amp;&amp; $_GET['page'] == $i){
    echo  $i;
    }
    else{
    echo "&lt;a href='admin_list.php?page=$i'&gt;$i&lt;/a&gt; ";
    }
    }  

    echo "&lt;/p&gt;";
    // close database connection
      $con-&gt;close();

?&gt;
&lt;/form&gt;

&lt;/div&gt;
</code></pre>