title: Field subtraction using Mysql
body: <p>Please could someone help me with this newbie problem I've been struggling with for some time now:</p>
  
  <p>The first part of my code below is a validation check that the team has sufficient funds available to purchase a player; the second part adds the player to the team sheet; but I also need to update the Teams table to remove the player's cost from the Available_Funds pending successful validation. </p>
  
  <p>My question is two-fold... the validation query doesn't work as is stands. I think I need to add a mysqli function around the $result&lt;0 check, but I'm not sure which one. I also need to update the Avaliable_Funds in the Teams table accordingly; but am unsure of the necessary syntax to combine this with the Insert Into statement. Any guidance on these two related issues would be gratefully received.</p>
  
  <p>This is the relevant section from my code as it stands. $Cost is a variable that's being posted correctly. (I've commented-out the parts that aren't currently working):</p>
  
  <pre><code>//$result = $mysqli-&gt;query("Select (Available_Funds-'{$Cost}') as check From Teams Where Team_ID = '{$Team}'");
      //if  ($result&lt;0) {$error.='&lt;p&gt;You have insufficient funds&lt;/p&gt;';}
  
  
  else
      $sql="Insert Into Players (Player_Name,Status,Type_ID,Team_ID) Values ('" . $player_name . "','Active','" . $Type . "','" . $Team . "')";
      $result = $mysqli-&gt;query($sql); }
  
  //$sql="Update Teams set Available_Funds=(Available_Funds-'{$Cost}')";
  $result = $mysqli-&gt;query($sql);
  </code></pre>
  
  <p>Many thanks in advance for any assistance on this one!</p>