Select count total and echo random image

Hello,

I have a question about how to select count from database and echo out.
For example i have in database categories videos like,

Cars | Family | Funny | etc.

And what i want to show is the total videos from that category and a random image, see picture below

https://www.dropbox.com/sh/244tharris3mbf4/AAA1bi7hqLVfXa24Xu-5S4Yfa?dl=0
and i want to do that for about 40 categories i have listed in my database.

Is that possible?

Thank in Advance

I dont know what language you’re using for your database. But it should be doable with the correct query.

For MySQL, something like the following should do you:

SELECT category, COUNT(*) as videocount FROM videos GROUP BY category ORDER BY category
1 Like