title: Dynamic checkboxes with the help of PHP
body: <p>I'm checking the database and if a particular string is matched, the respective <code>checkbox</code> gets checked but the error is whenever a string is matched, I'm getting two <code>checkboxes</code> checked, one <code>unchecked</code> and another <code>checked</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
       $result = mysqli_query($sql,"SELECT * FROM grsi "); 
       while($row = mysqli_fetch_array($result))
       {
           $focus=explode(",",$row['spr']);
  ?&gt;
  &lt;input type="checkbox" value=&lt;?php echo $row['spr']; if(in_array("Cricket",$focus)) { ?&gt; checked="checked" &lt;?php } ?&gt; name="focus[]" /&gt;Cricket
  &lt;?php
       }
    exit();
  ?&gt;
  </code></pre>