title: how to update mysql with php when subtracting
body: <p>I want to update a table with PHP and mySQL.
  I need to add or subtract whatever number I select from a value already in a mysql db.
  It works ok when I add to "player_qty" but not when I subtract/delete. 
  It gives me the message I want, that so many have been deleted but when I check the database, teh value is the same -- not deleting.</p>
  
  <pre><code>$register_query = "SELECT * FROM players WHERE player_id='$add_player_id' AND event_name = '$event_name'";
  $register_check = mysql_query($register_query, $db); 
  $register_found_users = mysql_num_rows($register_check);
  
  if($_POST['button'] == "Add") {
      if($register_found_users&gt;0){
      mysql_query("UPDATE players 
      SET  
      player_qty = player_qty + $add_player_qty,
      player_pickedup = '1', 
      event_user = '$event_user'  
      WHERE player_id = '$add_player_id'");
      $msg = $add_player_qty.' more ticket(s) added to '.$add_player_id.'.';
      } else {
      $insertSQL1 = "
      INSERT INTO players 
      (player_id, player_qty, player_adt, player_level, player_pickedup, event_name, event_type, event_end, event_user)
      VALUES 
      ('$add_player_id', '$add_player_qty', NULL, NULL, '1', '$event_name', '$event_type', '$event_end', '$event_user')";
      mysql_select_db($dbname, $db);
      $Result1 = mysql_query($insertSQL1, $db) or die(mysql_error()); 
      $msg = $add_player_id.' added to DB w/ '.$add_player_qty.' ticket(s)'; 
      }
  }elseif($_POST['button'] == "Delete") {
      if($register_found_users&gt;0){
      mysql_query("UPDATE players 
      SET  
      player_qty = player_qty - $add_player_qty,
      player_pickedup = '1', 
      event_user = $event_user 
      WHERE player_id = '$add_player_id'");
      $msg = $add_player_qty.' ticket(s) deleted from '.$add_player_id.'.';
      } else {
      $msg = $add_player_id.' not in database. Please add manually.'; 
      }
  } else {
      //
  }
        &lt;!-- FORM TO ADD PLAYER TO DATABASE IF DOESN'T EXIST --&gt;
        &lt;form action="" method="post" enctype="multipart/form-data" name="form_add_player" id="form_add_player" style="display:&lt;?php echo $css;?&gt;;"&gt;
  
            &lt;label for="add_player_id"&gt;PLAYER #: &lt;/label&gt;
            &lt;input type="text" name="add_player_id" id="add_player_id" value=""/&gt;
  
            &lt;label for="add_player_qty"&gt;QUANTITY: &lt;/label&gt;
            &lt;select name="add_player_qty" id="add_player_qty"&gt;
              &lt;option value="1"&gt;1&lt;/option&gt;
              &lt;option value="2" selected&gt;2&lt;/option&gt;
              &lt;option value="3"&gt;3&lt;/option&gt;
              &lt;option value="4"&gt;4&lt;/option&gt;
              &lt;option value="5"&gt;5&lt;/option&gt;
              &lt;option value="6"&gt;6&lt;/option&gt;
              &lt;option value="7"&gt;7&lt;/option&gt;
              &lt;option value="8"&gt;8&lt;/option&gt;
              &lt;option value="9"&gt;9&lt;/option&gt;
              &lt;option value="10"&gt;10&lt;/option&gt;
            &lt;/select&gt;
  
              &lt;input name="event_end" type="hidden" id="event_end" value="&lt;?php echo $row_get_type['event_end'];?&gt;" /&gt;
              &lt;input type="submit" name="button" value="Add" class="button"&gt;
              &lt;input type="submit" name="button" value="Delete" class="button"&gt;          
  
        &lt;/form&gt;
  </code></pre>