How do i find how many items there are per unique user in a data base
So say i have hats gloves and lots of other elements in my data base that users have added
how would i find how much each one had
eg hats- 35 t-shirts -50
but the problem is the categories would change so it would have to get all the categories then do an MySQL search on each of them... i have done lots of different MySQL tries and they have all failed here is one
$sql = "SELECT COUNT(username) FROM cards GROUP BY username";
$query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_row($query);
$users = $row[0];
and i dont know where to go from here
This is how you can do
select `item`,count(*) as `total` from `test`
group by `item`
check here
http://www.sqlfiddle.com/#!2/19250/1
You can change the query to have your field names in the query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.