I have page where i’m displaying only photo posts. I have query and foreach loop which display username, avatar and the post for each user. I want to display inside this foreach number of posts for each user. I’already have a SQL query which is count number of rows for every user
SELECT author, COUNT(1) AS `num` FROM video_posts GROUP BY author
The output in phpmyadmin is this:
But i can’t find a solution how to display this into php script for each user, while i already have another foreach loop. I try mysqli_fetch_all, mysqli_num_rows, mysqli_fetch_assoc, but nothing work for me. I hope you understand the question. Thanks.
Source: Ask PHP