0

我有以下 MySQL 查询

$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
    ");

在 phpMyAdmin 中返回以下结果

Joker sport | jokerCount
8           | 8

我认为下面的 php 会显示结果,但它不起作用。我应该写什么来回显结果?

$jokerResult = mysql_fetch_array($jokerQuery);
echo $jokerResult['Joker sport'];
echo $jokerResult['jokerCount'];
4

2 回答 2

1

试试这个,在mysql_fetch_arrayMYSQL_ASSOC中添加为 const :

$jokerResult = mysql_fetch_array($jokerQuery, MYSQL_ASSOC);
echo $jokerResult['Joker sport'];
echo $jokerResult['jokerCount'];
于 2012-10-08T21:42:46.403 回答
1

你也可以试试:

$jokerResult = mysql_fetch_array($jokerQuery, MYSQL_ASSOC);
print_r($jokerResult);

查看列名。

于 2012-10-08T22:50:59.090 回答