title: check the checkbox that has values coming from database in php
body: <p>when i submit my checked checkbox in the database i want to retain the checked check box.. please help me what to do with here.. this is only my snippet.. </p>
  
  <pre><code>&lt;?php
  if (isset($_POST['submit'])) {
      $radha        = $_POST['radha'];
      $radha_values = '';
      foreach ($radha as $val) {
          $radha_values .= $val . ",";
      }
      $sql = "INSERT INTO tbl_check (names) VALUES ('$radha_values')";
      $res = mysql_query($sql) or die("error:" . mysql_error());
      if ($res) {
          echo "added";
      }
      mysql_close();
  }
  $sql = "select names from tbl_check where id=2";
  $res = mysql_query($sql) or die("error:" . mysql_error());
  $row = mysql_fetch_array($res);
  $names = $row['names'];
  echo $names;
  ?&gt;
  &lt;form method="post" action="checkbox.php"&gt;
      &lt;input name="radha[]" type="checkbox" value="krishna"/&gt; krishna
      &lt;input name="radha[]" type="checkbox" value="gopala"/&gt;gopala
      &lt;input name="radha[]" type="checkbox" value="govinda"/&gt;govinda
      &lt;input name="radha[]" type="checkbox" value="haribol"/&gt;haribol&lt;br/&gt;
      &lt;input name="submit" type="submit" value="add"/&gt;
  &lt;/form&gt;
  </code></pre>