with the following query:
$result = mysql_query(
"SELECT Stats.champion
FROM Stats, Games
WHERE Stats.game_id = Games.game_id
AND Stats.win = 1
AND Games.game_mode = 'ODIN'");
I am returned the following dataset:
Ezreal
Garen
Pantheon
Ahri
Sion
Rammus
Nidalee
Poppy
Heimerdinger
Graves
KogMaw
Gangplank
Tristana
Fizz
Pantheon
Pantheon
Evelynn
MasterYi
Tryndamere
Leona
Vayne
Malphite
Graves
Shaco
Nidalee
Graves
Heimerdinger
Gangplank
JarvanIV
Akali
My goal is to count the result for each name. I know for one, for example “Pantheon”, I can do:
$result = mysql_query(
"SELECT Stats.champion
FROM Stats, Games
WHERE Stats.game_id = Games.game_id
AND Stats.champion = 'Pantheon'
AND Stats.win = 1
AND Games.game_mode = 'ODIN'");
$pantheonwins = mysql_num_rows($result);
echo $pantheonwins;
This results with the correct information!
Pantheon
Pantheon
Pantheon
3
So since this gives me the correct data, is this the most efficient way to get the win count for each individual name, then get a total number of records to computer percents?
Try changing your query to this:
Now, you should get the count along with the
championin the query result.