title: Insert Yes or No into MySQL based on checkbox value
body: <p>I have a list of checkboxes that look like below, the numbers, 416, 419, etc represent a page number.  They are for 2 sets of fields, one is "likebutton", the other is "sendbutton".</p>
  
  <pre><code> &lt;input type="checkbox" name="likebutton[]" value="416" /&gt;
   &lt;input type="checkbox" name="likebutton[]" value="417" /&gt;
   &lt;input type="checkbox" name="likebutton[]" value="418" /&gt;
   &lt;input type="checkbox" name="likebutton[]" value="419" /&gt;
   ...more checkboxes
   &lt;input type="checkbox" name="sendbutton[]" value="416" /&gt;
   &lt;input type="checkbox" name="sendbutton[]" value="417" /&gt;
   &lt;input type="checkbox" name="sendbutton[]" value="418" /&gt;
   &lt;input type="checkbox" name="sendbutton[]" value="419" /&gt;
   ...more checkboxes
  </code></pre>
  
  <p>What I am trying to achieve is when these checkboxes get checked, I am able to update each row (page) with the data of either Yes (Checked) or No (Unchecked) for both likebutton and sendbutton fields in MySQL.  Currently my mysql query look like something below.  This seems to work only when I have one foreach function and if I tick off one or more checkboxes, but if i leave the codes as stated below or If I have everything unchecked, I get an error for the foreach function.</p>
  
  <pre><code> foreach($_POST["likebutton"] as $pagenumberL)
   $YesNoL = isset($_POST["likebutton"]) ? 'Yes' : 'No';
   mysql_query("UPDATE pages SET likebutton='".$YesNoL."' WHERE page_id='".$pagenumberL."'");
  
   foreach($_POST["sendbutton"] as $pagenumberS)
   $YesNoS = isset($_POST["sendbutton"]) ? 'Yes' : 'No';
   mysql_query("UPDATE pages SET sendbutton='".$YesNoS."' WHERE page_id='".$pagenumberS."'");
  </code></pre>
  
  <p>Any pointer on my problem or better suggestion as to how I should proceed? </p>