ttocskcaj Posted March 24, 2011 Share Posted March 24, 2011 I have the following database for BigBrother, which is a plugin for CraftBukkit Minecraft server mod. What I want to do is get an array with `player` as the key and the value as the number of rows in the database for that player where action = 0 or 1. id date player action world x y z type data rbacked If that makes sense, what would be the best/most efficient way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/231574-query-problem/ Share on other sites More sharing options...
trq Posted March 24, 2011 Share Posted March 24, 2011 If that makes sense Sorry, none at all. Quote Link to comment https://forums.phpfreaks.com/topic/231574-query-problem/#findComment-1191647 Share on other sites More sharing options...
The Little Guy Posted March 25, 2011 Share Posted March 25, 2011 I think he wants this: $sql = mysql_query("select player, count(*) as total from my_table where action in(0,1) group by player"); while($row = mysql_fetch_assoc($sql)){ echo $row['player']."; Total: ".$row['total']."<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/231574-query-problem/#findComment-1192058 Share on other sites More sharing options...
ttocskcaj Posted March 27, 2011 Author Share Posted March 27, 2011 I think he wants this: $sql = mysql_query("select player, count(*) as total from my_table where action in(0,1) group by player"); while($row = mysql_fetch_assoc($sql)){ echo $row['player']."; Total: ".$row['total']."<br>"; } Yup that's exactly what I wanted. Thankyou. Quote Link to comment https://forums.phpfreaks.com/topic/231574-query-problem/#findComment-1192752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.