To get number of rows in result set there are two ways:
Is to use query to get count
$query=\"Select count(*) as count from some_table where type=
It depends on your implementation. If you're dealing with a lot of rows, count(*) is better because it doesn't have to pass all of those rows to PHP. If, on the other hand, you're dealing with a small amount of rows, the difference is negligible.