title: Returning sum from function
body: <p>I have a SQL table where I store the daily intake of water for the users. I want to select the user's intake for the current date. I think I am doing it right, just don't know how to return the number:</p>
  
  <pre><code>function intake_so_far(){
      $connection=get_db();
      $email=$_SESSION['email'];
      $datetoday=date("Y-m-d");
      $sql="SELECT SUM(intake_amount) FROM intake WHERE intake_email='$email' AND date(intake_date)='$datetoday'";
      $q=mysqli_query($connection,$sql);
  }
  </code></pre>
  
  <p>How should I return the <code>SUM</code> of (intake_amount) AS <code>$intake_so_far</code>?</p>
  
  <p>Hope you get what I want, huge thanks in advance!</p>