padams Posted September 21, 2007 Share Posted September 21, 2007 Is it possible to take an associative array and summarise its contents? I have an associative array where each row has an integer playerID field, and a few other fields. What I would like to do is count up how many rows there are for each playerID, and then display that information in a table. I've no idea if it's even possible, and if so, no idea where to start! The query looks like this: $tries_sql = "SELECT * FROM tries"; $tries_query = mysql_query($tries_sql) or die(mysql_error()); $rsTries = mysql_fetch_assoc($tries_query); Quote Link to comment https://forums.phpfreaks.com/topic/70127-solved-summarising-array-contents/ Share on other sites More sharing options...
phpwonderkid Posted September 21, 2007 Share Posted September 21, 2007 yeah you can use Groupby clause in your query something like select * from table where 1 groupby playerid Quote Link to comment https://forums.phpfreaks.com/topic/70127-solved-summarising-array-contents/#findComment-352203 Share on other sites More sharing options...
padams Posted September 21, 2007 Author Share Posted September 21, 2007 Awesome, I didn't know that existed. I've combined it with the COUNT function and it kicks out the results I'm after. Thanks! SELECT tryPlayer, COUNT(tryPlayer) FROM tries GROUP BY tryPlayer Quote Link to comment https://forums.phpfreaks.com/topic/70127-solved-summarising-array-contents/#findComment-352214 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.