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; ?> Quote 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]; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.