In my table Predictions, i put predictions of matches.
it looks like this:
PredictionID UserID GameID ScoreHome ScoreAway
1 1 1 2 1
2 2 1 4 2
3 3 1 1 1
4 4 1 1 3
Now i want to show, for each GameID, how much percentage predicts that the hometeam wins the game, loses the game, or draws the game.
In this case:
50 % predicts the hometeam will win
25 % predicts the game will end in a draw
25 % predicts the hometeam will lose
I use this code, but it gives me the following error:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in statistieken.php on line 12
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in statistieken.php on line 14
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in statistieken.php on line 16
<?
$winst = "SELECT
SUM(CASE WHEN ScoreHome > ScoreAway THEN 1 END) / COUNT(*) AS procentThuisWint*100,
SUM(CASE WHEN ScoreHome < ScoreAway THEN 1 END) / COUNT(*) AS procentThuisVerliest*100,
SUM(CASE WHEN ScoreHome > ScoreAway THEN 1 END) / COUNT(*) AS procentGelijkSpel*100
FROM Predictions";
$res =mysql_query($winst);
echo mysql_result($res,0,'procentThuisWint');
echo "<br>\n";
echo mysql_result($res,0,'procentThuisVerliest');
echo "<br>\n";
echo mysql_result($res,0,'procentGelijkSpel');
echo "<br>\n";
?>
I hope someone will help me!