im trying to TOTAL up the "adminprofits" field in sql database and display it, but it wotn work
echo "<strong>Admin Profits:</strong> ";
$mysql_result = mysql_query("SELECT SUM(adminprofits) FROM sales");
echo "$mysql_result<br /><br />";
please help, thanks
cant get SUM to work with PHP
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: cant get SUM to work with PHP
Any starting-php tutorial will have an example like this:
Code: Select all
$result = mysql_query('SELECT SUM(adminprofits) AS adminsales FROM sales');
$row = mysql_fetch_assoc($result);
echo $row['adminsales'];