If I\'m not mistaken this will give you the sum of the ID field which is 1 + 2 + 3 = 6. I think you should use the COUNT function. Change this line:
$query = "SELECT SUM(ID) AS totalrecords FROM table";
To this:
$query = "SELECT COUNT(*) AS totalrecords FROM table";
Or you could simplify it using the mysql_num_rows function like this:
[php:1:9228aa23a2]<?php
$conn = mysql_connect(\'dbhost\', \'dbuser\', \'dbpass\') or die(mysql_error());
mysql_select_db(\'dbname\', $conn) or die(mysql_error());
$query = \"SELECT * FROM table\";
$result = mysql_query($query, $conn) or die(mysql_error());
$totalrecords = mysql_num_rows($result);
echo \'Total Records \' . $totalrecords;
mysql_close($conn) or die(mysql_error());
?>[/php:1:9228aa23a2]