How to display SQL Sum query in html?

I’ve come up with an SQL sum query:

$query = "SELECT SUM(calories) FROM tracklog AS calories WHERE userid = $_SESSION[userid]";

No errors are shown, however how do I get this value to be displayed using HTML?

I want it to be displayed after ‘Total number of calories lost to date:’

It looks like your AS is in the wrong place. I think you want to alias the aggregate, not the table?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.