Thomisback Posted April 7, 2008 Share Posted April 7, 2008 Hi, I am trying to execute a MySQL query to find out how many members a game has, let me show you an example: members owner 12 admin 39 john 1 john 21 admin How can I count up the total members from the same owners? I have already tried various counts querys but they still do not count up the members from the same owners. Thank you! Link to comment https://forums.phpfreaks.com/topic/99931-mysql-count/ Share on other sites More sharing options...
BillyBoB Posted April 7, 2008 Share Posted April 7, 2008 Try this: <?php $i = 0; $select = mysql_query("SELECT * FROM table"); while($info = mysql_fetch_array($select)) { if(array_key_exists($info['owner'],$users)) { $users[$info['owner']] = $users[$info['owner']] + $info['members']; }else{ $users[$i] = $info['owner'] => $info['members']; } } print_r($users); ?> I hope this helps you I hand coded this in the textbox so there may be some errors. Link to comment https://forums.phpfreaks.com/topic/99931-mysql-count/#findComment-510981 Share on other sites More sharing options...
Thomisback Posted April 7, 2008 Author Share Posted April 7, 2008 Thanks a lot, going to try it now Link to comment https://forums.phpfreaks.com/topic/99931-mysql-count/#findComment-510994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.