How to get each db result value count
Not fully understanding the output you really want to achieve, but here's examples on how to count the results coming from the database

get count with db_select

OR

rowCount

Let me know if any of those work for you.