title: Dynamic PHP string as MySQL table name
body: <p>I have mySQL tables namely q1 , q2 , q3 and so on....</p>
  
  <p>now the following code is in loop with $n increasing with every step of loop.</p>
  
  <pre><code>$table = "q".$n;
  $query="SELECT MAX(QNO) AS max2 FROM '$table'";
  $q=mysqli_query($db,$query) or die("Error: ".mysqli_error($db));
  $max2 = mysqli_fetch_array($q);
  </code></pre>
  
  <p>This gives me an error</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"q1"' at line 1</p>
  </blockquote>
  
  <p>How to solve this problem and putting new name of table everytime in the query?</p>