title: How to use PHP to pass HTML form data to a MYSQL db and return the data to the browser
body: <p>I'm trying to use <code>PHP</code> to pass HTML form data to a <code>MYSQL</code> db and return the data to the browser. By submitting checked permissions (<code>M1</code>,<code>M2</code>,<code>MN1</code>..) i want to display Names of instructors who have those permissions. Now, please tell me what is wrong with the code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;form action="akcja.php" method="post"&gt;    
  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;th&gt;&lt;br/&gt;&lt;input type="checkbox" id="check" name="M1" value="M1,"&gt;m1&lt;/th&gt; 
  &lt;th&gt;&lt;br/&gt;&lt;center&gt;&lt;input type="checkbox" id="check" name="M2" value="M2,"&gt;m2&lt;/center&gt;&lt;/th&gt; 
  &lt;th&gt;&lt;br/&gt;&lt;center&gt;&lt;input type="checkbox" id="check" name="MN1" value="MN1,"&gt; mn1    &lt;/center&gt;&lt;/th&gt; &lt;/tr&gt;&lt;/table&gt;
  &lt;input type="submit" name="submit" value="Search Database" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  
  &lt;?php
  $query = mysql_query("SELECT * FROM permissions WHERE m LIKE '".$_POST['M1']."' OR m LIKE '".$_POST['M2']."' OR mn LIKE '".$_POST['MN1']."' ");  
  if($query)
      while($permissions = mysql_fetch_assoc($query)){
          $query2 = mysql_query("SELECT name_surname FROM instruktorzy WHERE instruktor_id='".$permissions['instruktor_id']."'");  
          while($Mdwa = mysql_fetch_assoc($query2)){
              echo "&lt;p style=\"font-size: 14px; font-family: Helvetica; background-color: #FFFFFF\"&gt; ".$Mdwa['name_surname']."&lt;br /&gt;" ; "&lt;/p&gt;" ;
          }
      }
  ?&gt;
  </code></pre>