You can add upon checkout.
Here's just a sample of what you want to use...
Code:
$item = $_GET['item']
$result = mysql_query("SELECT * FROM inventory
WHERE item='$item'") or die(mysql_error());
$row = mysql_fetch_array( $result );
$count = $row['count'] - 1;
$result = mysql_query("UPDATE inventory SET count='$count' WHERE item='$item'")
or die(mysql_error());