Jump to content

Recommended Posts

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>';
}

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-522090
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523627
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-523692
Share on other sites

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..

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524174
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524414
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524421
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-524641
Share on other sites

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..

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525192
Share on other sites

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>';
}

Link to comment
https://forums.phpfreaks.com/topic/101953-solved-function-help/#findComment-525757
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.