title: PHP, SQL limit query by php variable
body: <p>PHP code defining variable sqlshowvalue</p>
  
  <pre><code>$sqlshowvalue = 5;
  if(isset($_POST['showmore'])) {
       $sqlshowvalue += 5;
  }
  </code></pre>
  
  <p>So I connect to my database and then when I run this SQL query below using the variable that I just defined above,</p>
  
  <pre><code>$result = mysqli_query($conn,"SELECT * FROM comments ORDER BY id DESC limit '$sqlshowvalue'");
  </code></pre>
  
  <p>So I am using mysqli as the method to connect to my DB and it gives me the following error:</p>
  
  <pre><code>Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in ..
  </code></pre>
  
  <p>The reason it gives me this error is because something in my query is wrong and what it has to do is $sqlshowvalue, because if I replace sqlshowvalue with with just the number 5 (like shown below), it works fine:</p>
  
  <pre><code>$result = mysqli_query($conn,"SELECT * FROM comments ORDER BY id DESC limit 5");
  </code></pre>
  
  <p>So I am just wondering what I can do to make it so that the value for the limit is a PHP variable that I can be changed and the page updated.</p>