Reputation: 23804
I have the following MySQL query
$jokerQuery = mysql_query("SELECT `Joker sport`,
COUNT(`Joker sport`) AS jokerCount
FROM Profiles
WHERE `CompetitorID` = 5
GROUP BY `Joker sport`
ORDER BY COUNT(`Joker sport`) DESC
LIMIT 1
");
which returns the following result in phpMyAdmin
Joker sport | jokerCount
8 | 8
I thought the following php would display the result but it doesn't work. What should I write to echo the result?
$jokerResult = mysql_fetch_array($jokerQuery);
echo $jokerResult['Joker sport'];
echo $jokerResult['jokerCount'];
Upvotes: 0
Views: 237
Reputation: 167
You can also try:
$jokerResult = mysql_fetch_array($jokerQuery, MYSQL_ASSOC);
print_r($jokerResult);
to see column names.
Upvotes: 1
Reputation: 5239
try this, add MYSQL_ASSOC
as the const in mysql_fetch_array:
$jokerResult = mysql_fetch_array($jokerQuery, MYSQL_ASSOC);
echo $jokerResult['Joker sport'];
echo $jokerResult['jokerCount'];
Upvotes: 1