title: problem in updating a row in database using mysqli
body: <p>there is table named Book and this code is supposed to find a specific record and edit it's num to num-1, but it only edit num to -1.</p>
  
  <pre><code>$sql = 'SELECT num FROM Book
      WHERE bid="'.$_SESSION["sails bid{$i}"].'"';
  if (mysqli_query($conn, $sql)) {
      $row = mysqli_fetch_array($query);
      $numbers=(int)$row['num']-1;
      $sql='UPDATE Book
      SET num="'.$numbers.'"
      WHERE bid="'.$_SESSION["sails bid{$i}"].'"';
      if (mysqli_query($conn, $sql)) {
          ...
      }
  }
  </code></pre>