title: How would I implement pagination through php get requests
body: <p>I have some code that supports pagination, but I can't make my buttons work. Can anyone help?</p>
  <pre><code>function setData() {
  var flexContainer = document.getElementById(&quot;flex&quot;);
  flexContainer.innerHTML = &quot;&lt;?php 
    foreach ($articlesarray as $seperated) {
      $contentsContent = file_get_contents(&quot;../&quot; . &quot;$seperated[contentsname]&quot;);
      echo &quot;&lt;div class='card'&gt;&lt;img src='$seperated[img]'' alt='uh oh photo not found' style='width:100%''&gt;&lt;div class='container'&gt;&lt;h4&gt;&lt;b&gt;$seperated[title]&lt;/b&gt;&lt;/h4&gt;&lt;p&gt;$contentsContent&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&quot;;
    }
   ?&gt;&quot;;
  document.getElementById(&quot;back&quot;).disabled = &quot;&lt;?php 
    if ($_SERVER['REQUEST_URI'] == &quot;/list/index.php?page=1&quot;) {
      echo &quot;true&quot;;
    } else {
      echo &quot;false&quot;;
    }
  ?&gt;&quot;;
  document.getElementById(&quot;back&quot;).style = &quot;&lt;?php 
    if ($_SERVER['REQUEST_URI'] == &quot;/list/index.php?page=1&quot;) {
      echo &quot;display: none;&quot;;
    } else {
      echo &quot;display: inline-block;&quot;;
    }
  ?&gt;&quot;;
  </code></pre>
  <p>}</p>
  <p>and the php is:</p>
  <pre><code>$servername = &quot;localhost&quot;;
  $username = &quot;root&quot;;
  $password = &quot;You can't have my server password&quot;;
  $dbname = &quot;myDB&quot;;
  
  $badurl = &quot;/list/index.php&quot;;
  $newURL = &quot;/list/index.php?page=1&quot;;
  
  if ($_SERVER['REQUEST_URI']==$badurl) {
    print &quot;uh oh spaghettios&quot;;
    header('Location: ' . $newURL);
    die();
  }
  
  $conn = new mysqli($servername, $username, $password, $dbname);
  
  if ($conn-&gt;connect_error) {
    die(&quot;Connection failed: &quot; . $conn-&gt;connect_error);
  }
  
  $offsetAmount = $_GET[&quot;page&quot;] * 9 - 9;
  
  $sql = &quot;SELECT id, title, contentsname, img FROM articles LIMIT 9 OFFSET $offsetAmount&quot;;
  $result = $conn-&gt;query($sql);
  
  $articlesarray = array();
  
  while($row = mysqli_fetch_assoc($result)){
     $articlesarray[] = $row;
  }
  
  //echo &quot;&lt;br&gt;&lt;br&gt;&lt;br&gt; If you are reading this, you have found the debug screen. This website is under maintanence.&quot;;
  
  mysqli_close($conn);
  </code></pre>
  <p>I can't work out how to add pagination using this system. Can anyone help? I have tried shifting the url but that only returned a 0 for some reason.</p>