title: php+mysql : increase a cell's value without checking it?
body: <p>I've got a form with checkboxes set to bitwise values (CB1=1,CB2=2,CB3=4,CB4=8), and I want to store their sum in a single cell (to avoid having empty fields). The checkboxes have the same name but different values, and the data is sent to the processing php script as a serialised string, ie <code>name=value&amp;name=value2&amp;name3=value3&amp;name=&amp;name=value5</code></p>
  
  <p>Currently I can separate the string and get the values into the proper cells rather efficiently/easily. But, I'm wondering if there is a way to insert the first value into the cell then add subsequent values to the same cell. I imagine it would look something like this:</p>
  
  <pre><code>foreach ( $qaPairs as $pair ) {
      list($question , $answer) = explode('=', $pair);
      // ^ splits Q1=A1 into $question=Q1 and $answer=A1
  
      // this mysql_query is a modified version of what I'm currently using
      mysql_query("UPDATE $table SET `$question`=`$question`+'$answer' WHERE `key`='$key';") or die(mysql_error());
      // $question is also the name of the column/field
  
  } // end foreach
  </code></pre>
  
  <p>I dunno if it makes a difference, but: there are other datatypes (besides bitwise integers, such as text) and other form types (like textfields).</p>
  
  <p>P.S. I would rather not have to somehow check if there are multiple instances of the same name and then do addition.</p>
  
  <p>P.P.S. I got the UPDATE idea from this question: <a href="https://stackoverflow.com/q/3651883/758177"><a href="https://stackoverflow.com/q/3651883/758177">MySQL Batch increase value?</a></a>, and I tried it out, but it didn't update <code>null</code> values (which I need it to do).</p>
  
  <p>Thanks in advance!</p>