Mysql Get Query Digest

require(constant("sec_inc").'/config.php');
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbname);

Fetch:

$query = "select * from table_name  where field='".$var."'";//Don't forget escaping...
mysql_query("SET NAMES 'utf8'", $link);
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result))
{

         //Bla Bla Bla

}

 

Count:

$query = "select count(*) from table_name  where field='".$var."'";//Don't forget escaping...
$row=mysql_fetch_row($result);
$count = $row[0];