title: Update database with checkbox php mysql
body: <p>I want to update the database with a checkbox in checked state.</p>
  
  <ul>
  <li>If it is checked then update the database with 1.</li>
  <li>Else if it is unchecked then update it with 0.</li>
  </ul>
  
  <p>It works fine but it doesn't work if unchecked.</p>
  
  <pre><code>&lt;?php 
  include('lib/db.php');
  
  $facebook_id ="10001088";
  $query1 = "SELECT `video`,`quran`,`medical`,`groups`  FROM `man_facebook`.`users` WHERE `facebook_id`='$facebook_id'";
          $result1 = mysql_query($query1);
  while($result = mysql_fetch_array($result1))
  {
      $video = $result['video'];
      $quran = $result['quran'];
      $medical = $result['medical'];
      $groups = $result['groups'];
      echo $video;
   //   echo $quran;
  ?&gt;
  
  &lt;form method="post"  action="&lt;? echo $_SERVER['REQUEST_URI']; ?&gt;" &gt;
  
  &lt;input type="checkbox" name="video" id="video" value="&lt;?echo $video;?&gt;" &lt;?php
  if($video == '1'){
       echo "checked='checked'";
  }
   else {}
  echo "/&gt;"
  ?&gt; 
   &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;?php
  }
   if (isset($_POST['submit']))
  {
   if (is_numeric($_POST['video']) &amp;&amp; $_POST['video'] &lt;2 )
  {
   $video1 = isset($_POST['video']) ? '1' : '0';
  
  
   echo $video1;
      $query = mysql_query("UPDATE `man_facebook`.`users` 
  SET `video` ='$video1'
  WHERE `facebook_id`='$facebook_id'");
  
  $video = $video1;
  echo '&lt;meta http-equiv="refresh" content="0" /&gt;';
  
      }
      }
  //echo $query;
   //header("Location: updatesql.php"); 
  
  ?&gt;
  </code></pre>
  
  <p>Can I also use jquery to update it smoothly?</p>