$sql = "select count(*) from mytable"; $result = mysql_query($sql, $connection); $row = mysql_fetch_row($result); $total = $row[0];