title: Pagination in PHP not working on same page?
body: <p>I am developing a job portal where i have search box in my index page and for that i tried for pagination but pagination is not working and also if we click number it displaying nothing</p>
  
  <p>i can't figure out the mistakes, results displaying , numbers button, is working perfectly but when click on number  it is displaying nothing Here is my code</p>
  
  <pre><code>&lt;?php
      if( $user-&gt;is_logged_in() ){ header('Location: /emprdash'); } 
      if( ! empty($_SESSION['uid']))
      {
      header('Location: /emdash'); 
      }
      ?&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-12"&gt;
                  &lt;form action="" method="post"  &gt;
                      &lt;div id="adv-search" class="input-group"&gt;
                          &lt;input class="form-control" name="term" id="term"  type="text" placeholder="Search for jobs" required /&gt;
                          &lt;div class="input-group-btn"&gt;
                              &lt;div class="btn-group"&gt;&lt;button class="btn btn-primary" name="submit" type="submit" value="search"  &gt;Search&lt;/button&gt;&lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;br/&gt;
      &lt;br/&gt;
      &lt;?php 
          if(isset($_POST['submit']))
          { 
          $limit=1;
          $p=$_GET['p']=="" ? 1:$_GET['p'];
          $start=($p-1)*$limit;
          $status='active';
          $term =  $_POST['term'];     
          $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $stmt = $db-&gt;prepare("SELECT * FROM job WHERE status='active' AND  ( jdesc LIKE '%".$term."%' OR  jtitle LIKE '%".$term."%' OR duration  LIKE '%".$term."%' OR budget  LIKE '%".$term."%' OR  keyskills  LIKE '%".$term."%' OR jdate  LIKE '%".$term."%' OR edate  LIKE '%".$term."%' OR cdexmin  LIKE '%".$term."%' OR cdexmax  LIKE '%".$term."%' ) ORDER BY jid DESC LIMIT $start,$limit  "); 
          $stmt-&gt;execute();
          $rows = $stmt-&gt;rowCount(); 
          ?&gt;
      &lt;?php if($rows&gt;=1){ ?&gt;
      &lt;table class="table  table-responsive  table-inverse table-hover table-striped" &gt;
          &lt;thead&gt;
              &lt;tr class="info"&gt;
                  &lt;th&gt; JobTitle&lt;/th&gt;
                  &lt;th&gt;Duration&lt;/th&gt;
                  &lt;th&gt;Budget&lt;/th&gt;
                  &lt;th&gt;Key Skills&lt;/th&gt;
                  &lt;th&gt;Posted Date&lt;/th&gt;
                  &lt;th&gt;Expiry Date&lt;/th&gt;
                  &lt;th&gt;Experience Minimum&lt;/th&gt;
                  &lt;th&gt;Experience Maximum&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;?php while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
                  $jid=$row['jid'];
                  $repl = '&lt;span class="highlight"&gt;' . $term . '&lt;/span&gt;';
                  ?&gt;
              &lt;tr class="success"&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;a href="/showjob?jid=&lt;?php echo $row['jid']; ?&gt;"&gt;&lt;?php echo ucwords(str_ireplace($term, $repl, $row['jtitle'])); ?&gt;&lt;/a&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo str_ireplace($term, $repl, $row['duration']); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo str_ireplace($term, $repl, $row['budget']); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo str_ireplace($term, $repl, $row['keyskills']); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php $jdate=strtotime( $row['jdate']);  echo str_ireplace($term, $repl, date('d/M/Y',$jdate)); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php $edate=strtotime( $row['edate']);  echo str_ireplace($term, $repl, date('d/M/Y',$edate)); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo str_ireplace($term, $repl,$row['cdexmin']);  ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p&gt;&lt;?php echo str_ireplace($term, $repl,$row['cdexmax']); ?&gt;&lt;/p&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;form method="POST" action=""&gt;
                          &lt;input type="hidden" name="jid" value="&lt;?php echo $jid; ?&gt;" &gt;
                          &lt;center&gt;&lt;button type="submit"  name="apply" class="btn btn-outlined btn-primary" &gt;Login to Apply&lt;/button&gt;&lt;/center&gt;
                      &lt;/form&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php
                  }
                   ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;?php } else {
          echo '&lt;center&gt;&lt;div class="well"&gt;No results to display&lt;/div&gt;&lt;/center&gt;';} ?&gt;
      &lt;?php
          $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $stmt = $db-&gt;prepare("SELECT * FROM job WHERE status='active' AND  ( jdesc LIKE '%".$term."%' OR  jtitle LIKE '%".$term."%' OR duration  LIKE '%".$term."%' OR budget  LIKE '%".$term."%' OR  keyskills  LIKE '%".$term."%' OR jdate  LIKE '%".$term."%' OR edate  LIKE '%".$term."%' OR cdexmin  LIKE '%".$term."%' OR cdexmax  LIKE '%".$term."%' )  "); 
          $stmt-&gt;execute();
          $count= $stmt-&gt;rowCount(); 
          $countP=(ceil($count/$limit)) + 1;
          $tW=($countP*50) + $countP;
          echo"&lt;center style='overflow-x:auto;margin-top:10px;padding-bottom:10px;'&gt;";
          echo"&lt;div style='width:".$tW."px'&gt;";
          for($i=1;$i&lt;$countP;$i++){
          $isC=$i==$_GET['p'] ? "b-green":"";
          echo "&lt;a href='?p=$i'&gt;&lt;button class='pgbutton $isC'&gt;$i&lt;/button&gt;&lt;/a&gt;";
          }
          echo"&lt;/div&gt;";
          echo"&lt;/center&gt;";
          ?&gt;
      &lt;?php } ?&gt;
      &lt;?php
          if(isset($_POST['apply'])) 
          {
          $jobid=$_POST['jid'];
          $_SESSION['url'] = "/applyjob?jid=$jobid"; 
          header("Location:/login");
          }
          ?&gt;
  &lt;style&gt;
      .pgbutton{
      width:45px;
      margin:0px 5px;
      }
  &lt;/style&gt;
  </code></pre>