Two options:
You can either run an SQL query that just returns the number of rows that match;
SELECT COUNT(1) AS numrows FROM table WHERE foo=bar;
or you can run the query and get the number in PHP (but this will fetch all rows and send them to PHP, which is a waste of resources if you only want the number of rows and not the rows themselves)
$result = mysql_query('SELECT foo WHERE bar');
echo $mysql_num_rows($result);