title: How to get data from mysql database?
body: <p>I am having problem in getting values from db. Iam new in php</p>
  
  <p>I am using checkboxes to get values from database. Only checked values should be printed.</p>
  
  <pre><code>&lt;form method="POST" action="gradoviexport.php"  id="searchform"&gt;
  &lt;div id="GRADOVI BIH"&gt;
  &lt;h3&gt;GRADOVI BOSNE I HERCEGOVINE&lt;/h3&gt;&lt;hr/&gt;
  &lt;input type="checkbox" name="gradovi[]" value="sarajevo"&gt; Sarajevo
  &lt;input type="checkbox" name="gradovi[]" value="banovici"&gt; Banovići 
  &lt;input type="checkbox" name="gradovi[]" value="banjaluka"&gt;  Banja Luka
  &lt;input type="checkbox" name="gradovi[]" value="bihac"&gt;  Bihać
  &lt;input type="checkbox" name="gradovi[]" value="bileca"&gt; Bileća
  &lt;/div&gt;
  &lt;div id="snimi"&gt;
  &lt;input type="submit" name="submit" value="EXPORT"&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If Sarajevo is checked I want to print values from database. It does not have to be only one value checked If all values are checked it should print all values.</p>
  
  <pre><code>$con=mysqli_connect("$host","$username","$password", "$database");
  // Check connection
  if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
   //connecting to db     
  $variable=$_POST['grad'];
  foreach ($variable as $variablename)
  {
  $sql_select="SELECT * FROM `clanovi` WHERE `GRAD` = $variablename " ;
  $queryRes = mysql_query($sql_select);
  print"$sql_select";
  
  }
  echo "&lt;table border='5'&gt;
  &lt;tr&gt;
  &lt;th&gt;IME&lt;/th&gt;
  &lt;th&gt;PREZIME&lt;/th&gt;
  &lt;th&gt;FIRMA&lt;/th&gt;
  &lt;th&gt;ADRESA&lt;/th&gt;
  &lt;th&gt;TELEFON&lt;/th&gt;
  &lt;th&gt;FAX&lt;/th&gt;
  &lt;th&gt;MOBITEL&lt;/th&gt;
  &lt;th&gt;EMAIL &lt;/th&gt;
  &lt;th&gt;WEB_STRANICA &lt;/th&gt;
  &lt;th&gt;GRAD &lt;/th&gt;
  &lt;th&gt;KATEGORIJA &lt;/th&gt;
  
  &lt;/tr&gt;";
  
  while($row = mysqli_fetch_array($queryRes))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['IME'] . "&lt;/td&gt;"; 
  echo "&lt;td&gt;" . $row['PREZIME'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['FIRMA'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['ADRESA'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['TELEFON'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['FAX'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['MOBITEL'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['EMAIL'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['WEB_STRANICA'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['GRAD'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['KATEGORIJA'] . "&lt;/td&gt;";
  
  
  echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  
  mysqli_close($con);
  </code></pre>