lmhart Posted October 20, 2009 Share Posted October 20, 2009 I have a table that I can query the sum from with mysql and it gives a number but I can not get it to output to a php page. I get a resource id#3 <?php include 'dbc.php'; $result = mysql_query("SELECT sum(record_amount) as total_expense from record"); echo $result ?> Link to comment https://forums.phpfreaks.com/topic/178390-solved-echo-the-sum-of-a-field-in-a-table/ Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 Use mysql_fetch_row. Link to comment https://forums.phpfreaks.com/topic/178390-solved-echo-the-sum-of-a-field-in-a-table/#findComment-940746 Share on other sites More sharing options...
mikesta707 Posted October 20, 2009 Share Posted October 20, 2009 you have to use one of PHP's mysql_fetch_xxxx to get the results from your query include 'dbc.php'; $result = mysql_query("SELECT sum(record_amount) as total_expense from record"); $row = mysql_fetch_assoc($result); echo $ow['total_expense']; Edit: beat me to it Link to comment https://forums.phpfreaks.com/topic/178390-solved-echo-the-sum-of-a-field-in-a-table/#findComment-940747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.