whiteboikyle Posted April 20, 2008 Share Posted April 20, 2008 Games statistic forum.. gamesplayed list all the games available with the ID number member is the members profile with the main game selected i am trying to make a statistic to count all the numbers for each main game. here is my function so far function getGameStats() { global $dbprefix; $query = "SELECT * FROM {$dbprefix}gamesplayed"; $result = mysql_query($query) or die(mysql_error()); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>'; for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $gamepic = mysql_result($result, $i, "gamepic"); $gamename = mysql_result($result, $i, "gamename"); $id = mysql_result($result, $i, "ID"); $query = "SELECT maingame, COUNT('".$id."') FROM {$dbprefix}members GROUP BY maingame"; $result = mysql_query($query) or die(mysql_error()); $stat = mysql_result($result); echo ("<td><div align='center'>$stat</div></td>"); } echo ' </tr> </table>'; } Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/ Share on other sites More sharing options...
jonsjava Posted April 20, 2008 Share Posted April 20, 2008 I'm sorry, but it's 2:00am here, and my brain is fried. can you try to explain more in-depth what it is you are wanting? Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-521761 Share on other sites More sharing options...
whiteboikyle Posted April 20, 2008 Author Share Posted April 20, 2008 Gaming statistic.. it shows how many of each game a member has picked... dono how to explain it but above should Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-521766 Share on other sites More sharing options...
whiteboikyle Posted April 20, 2008 Author Share Posted April 20, 2008 bump sorry i need help and i need this quick =/ I am trying to count every member that has each game picked.. so if member kyle has picked maingame 1 member joe has picked maingame 2 member crypt has picked maingame 1 first it find that each number is a certain game like this 1 = CS 1.6 2 = CSS then it would count and show up like this CS 1.6 CSS 2 1 Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-522090 Share on other sites More sharing options...
GingerRobot Posted April 20, 2008 Share Posted April 20, 2008 What's your database structure? Sounds like a fairly simple join... Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-522091 Share on other sites More sharing options...
whiteboikyle Posted April 21, 2008 Author Share Posted April 21, 2008 What are you talking about? i explained everything above. Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-522424 Share on other sites More sharing options...
whiteboikyle Posted April 21, 2008 Author Share Posted April 21, 2008 bump? Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523111 Share on other sites More sharing options...
whiteboikyle Posted April 22, 2008 Author Share Posted April 22, 2008 Bump please!!! <3<3<3<3<3 Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523624 Share on other sites More sharing options...
monkeypaw201 Posted April 22, 2008 Share Posted April 22, 2008 right, either you are a expecting help without even providing grammatically correct or clear sentences or english isn't your strong point. in either case, this forum is for troubleshooting already made code, not for us to make you code with a wave of your hand. try posting a CLEAR description of whats going on and some code and we'll work from there Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523627 Share on other sites More sharing options...
whiteboikyle Posted April 22, 2008 Author Share Posted April 22, 2008 i did post what i have "tried" and it wont work.. and i dont get what you dont understand.. Its a table USERNAME PASSWORD ID MAINGAME if there is 5 games and they are all filled and there 2 is 2 types of main games (1 and 2) And 3 of them have 2 and 2 of them have 3 i want it to count it Main game 2 = 3 Main Game 3 = 2 Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523692 Share on other sites More sharing options...
GingerRobot Posted April 22, 2008 Share Posted April 22, 2008 So you want a count of each different maingame? SELECT COUNT(*),maingame FROM tbl GROUP BY maingame Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523704 Share on other sites More sharing options...
whiteboikyle Posted April 22, 2008 Author Share Posted April 22, 2008 like honestly if you look at my function you will see i have that.. and maybe see what i am trying to get done function getGameStats() { global $dbprefix; $query = "SELECT * FROM {$dbprefix}gamesplayed"; $result = mysql_query($query) or die(mysql_error()); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>'; for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $gamepic = mysql_result($result, $i, "gamepic"); $gamename = mysql_result($result, $i, "gamename"); $id = mysql_result($result, $i, "ID"); $query = "SELECT maingame, COUNT('".$id."') FROM {$dbprefix}members GROUP BY maingame"; $result = mysql_query($query) or die(mysql_error()); $stat = mysql_result($result); echo ("<td><div align='center'>$stat</div></td>"); } echo ' </tr> </table>'; } Pretty much count all the $ID's there is about 10 ID is a variable that hold all of them.. Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524174 Share on other sites More sharing options...
GingerRobot Posted April 22, 2008 Share Posted April 22, 2008 Perhaps its just me, but i've still no idea what the problem is. I've tried to follow what you've said, but havn't been able to. What does the above code currently do? Are there any errors? What is it supposed to do? See if you can answer those questions clearly and concisely and perhaps we'll get somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524414 Share on other sites More sharing options...
monkeypaw201 Posted April 22, 2008 Share Posted April 22, 2008 Perhaps its just me, but i've still no idea what the problem is. I've tried to follow what you've said, but havn't been able to. What does the above code currently do? Are there any errors? What is it supposed to do? See if you can answer those questions clearly and concisely and perhaps we'll get somewhere. same here..again Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524421 Share on other sites More sharing options...
whiteboikyle Posted April 23, 2008 Author Share Posted April 23, 2008 Okay there is a Mysql DATABASE with 2 Tables 1 is GamesPlayed another is Members In games played there are the following fields: id gamename gamepic statnames outsidelink In Members there the following fields: ID Username Password maingame The main game field is an ID from the GamesPlayed Table.. So.. there are 5 members lets say and there are 3 games.. and its filled out like this ID: 1 Username: Joe Password: test maingame: 1 ID: 2 Username: Bob Password: test maingame: 1 ID: 3 Username: kiddney Password: test maingame: 3 ID: 4 Username: sally Password: test maingame: 1 ID: 5 Username: sid Password: test maingame: 2 now i am trying to write a function that that pulls out the ID number from the Members page of each members and counts them. So it should return Main Game: 1 Members = 3 Main Game: 2 Members = 1 Main Game: 3 Members = 1 Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524641 Share on other sites More sharing options...
whiteboikyle Posted April 23, 2008 Author Share Posted April 23, 2008 Here let me show you visually since you guys dont understand. http://clan-hd.com/index.php?p=Members See where it Says GAME! on all the member! I am making a statistic!! where it counts all the people with each game.. so look at my function.. i know its almost right but it keeps coming up blank.. Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525192 Share on other sites More sharing options...
whiteboikyle Posted April 23, 2008 Author Share Posted April 23, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525578 Share on other sites More sharing options...
whiteboikyle Posted April 24, 2008 Author Share Posted April 24, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525726 Share on other sites More sharing options...
whiteboikyle Posted April 24, 2008 Author Share Posted April 24, 2008 my function updated.. it shows the games.. but the count is messed up. it comes out for every game 1 as the count. here is the code function getGameStats() { global $dbprefix; $query = "SELECT * FROM {$dbprefix}gamesplayed"; $result = mysql_query($query) or die(mysql_error()); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>'; for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $gamepic = mysql_result($result, $i, "gamepic"); $gamename = mysql_result($result, $i, "gamename"); $id = mysql_result($result, $i, "ID"); $query1 = "SELECT 'id' FROM {$dbprefix}members WHERE maingame = $id"; $result1 = mysql_query($query1) or die(mysql_error()); $stat = mysql_num_rows($result1); $stat = count($stat); echo ("<td><div align='center'><img src='$gamepic' alt='$gamename'> $stat</div></td>"); } echo ' </tr> </table>'; } Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525757 Share on other sites More sharing options...
sasa Posted April 24, 2008 Share Posted April 24, 2008 SELECT maingame, COUNT(ID) as count FROM Members GROUP BY maingame ORDER BY maingame Quote Link to comment https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525809 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.