Right in this case use COUNT() rather than SUM(), however as long as you have an AUTO_INCREMENT field asterisks are NOT needed. Also note that COUNT(expr) returns a count of the number of non-NULL values in the rows retrieved by a SELECT statement, while COUNT(*) returns a count of the number of rows retrieved, whether or not they contain NULL values. Do not be tempted to use mysql_num_rows(), using COUNT(expr) or COUNT(*) is a lot faster.
[php:1:3b0788305a]<?php
$conn = mysql_connect(\'dbhost\', \'dbuser\', \'dbpass\') or die(mysql_error());
mysql_select_db(\'dbname\', $conn) or die(mysql_error());
$query = \"SELECT COUNT(ID) AS totalrecords FROM table\";
$result = mysql_query($query, $conn) or die(mysql_error());
$row = mysql_fetch_assoc($result) or die(mysql_error());
$totalrecords = $row[\'totalrecords\'];
echo \'Total Records \' . $totalrecords;
mysql_close($conn) or die(mysql_error());
?>[/php:1:3b0788305a]