title: Sum of column in using mysqli and php
body: <p>I am tring to get the sum of a column and the show it on my page using this code but it keeps returning a "1" when it should return "23" for example. I check my sql statement and it works fine. This is the code I am using. (note: My server is iis with php)</p>
  
  <pre><code>&lt;?php
  require('connection.php');
  
  $sql="SELECT sum(amount) as total FROM td";
  
  $result = mysqli_query($sql);
  
  while ($row = mysqli_fetch_assoc($result)){ echo $row['total'];}
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>ok so I added the while thing and it just breaks my code I get a white page.</p>
  
  <p>I now removed the ! in the mysqli_query and I still get a white page, not sure if its me or the server that is not playing nice.</p>
  
  <p>This may be unrelated but when I removed the ! from the mysqli_query from my other code it broke it.</p>
  
  <pre><code>&lt;?php
  require 'connection.php';
  $date = $_POST['date'];
  $comment = $_POST['comment'];
  $amount = $_POST['amount'];
  
  $sql= "INSERT INTO td (date, comment, amount) VALUES ('$date', '$comment', '$amount')";
  
  if (mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
  echo "1 record added";
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>Everything is fixed Thanks Everyone!!!</p>