title: php select entire table and set variables from multiple rows by id
body: <p>I am very new to PHP so if this answer is out there already I apologize.  I have a table that looks like this:</p>
  
  <pre><code>mcID | mcName
  -------------
  M1   | M1name
  M2   | M2name
  M3   | M3name
  M4   | M4name
  </code></pre>
  
  <p>I know how to write four separate sql select statements to get these into variables but that seems like overkill.  I am wondering if there is a way to run a single select statement to set all four variables.  My current code to set one variable is below:</p>
  
  <pre><code>$sql = "SELECT * FROM tblmaincircles WHERE mcID='M1'";
  $result = $conn-&gt;query($sql);
  if($result-&gt;num_rows &gt; 0) {
  
      while($row = $result-&gt;fetch_assoc()) {
  
          $M1 = $row["mcName"];
      }
  }
  else {
  echo "0 results";
  }
  </code></pre>
  
  <p>Any help on this would be greatly appreciated.  I have a feeling I am missing something really basic.  Thanks!</p>