1) Count record:
//Connect to mysql server $link = mysql_connect(HOST, USER, PASSWORD); if(!$link) { die(\'Could not connect to server: \' . mysql_error());
When you only need the count the record, you should use COUNT() function of mysql, instead of load all of the records.
COUNT()
$query="SELECT COUNT(*) AS num FROM `table` WHERE `abc`='123'";
Second, use PDO instead of mysql_ functions.
PDO
mysql_