droidus Posted August 23, 2011 Share Posted August 23, 2011 am i going about this in the right way? it doesn't seem to be echoing anything <?php mysql_select_db($database_uploader, $uploader); $totalHits = mysql_query("SELECT SUM(hits) AS totalHits FROM userDataTracking") or die(mysql_error()); mysql_close($con); echo $totalHits; ?> Link to comment https://forums.phpfreaks.com/topic/245475-echoing-total-hits-for-a-page/ Share on other sites More sharing options...
DavidAM Posted August 23, 2011 Share Posted August 23, 2011 mysql_query returns a resource, you have to fetch the data using the resource: mysql_select_db($database_uploader, $uploader); $totalHits = mysql_query("SELECT SUM(hits) AS totalHits FROM userDataTracking") or die(mysql_error()); // Add this line to fetch the data $row = mysql_fetch_row($totalHits); mysql_close($con); // Access the data from the array echo $row[0]; Link to comment https://forums.phpfreaks.com/topic/245475-echoing-total-hits-for-a-page/#findComment-1260785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.