我想查询数据库以显示列中最常见的3个值(TyreMan)。然后显示值和出现次数
$sqlCommand = "SELECT TyreMan, COUNT(TyreMan) AS countTyreMan
FROM Pictures WHERE Tyreman IS NOT NULL AND Tyreman <> 'UNKNOWN'
GROUP BY TyreMan ORDER BY countTyreMan ASC LIMIT 3";
$query = mysql_query($sqlCommand) or die (mysql_error());
while ($row = mysql_fetch_array($query)) {
$manu = $row["TyreMan"];
echo "$manu";
目前我得到了
value1value2value3
我如何获得计数并像这样显示?
value1 [count], value2 [count], value3 [count]
感谢
答案 0 :(得分:0)
将计数转换为字符串并将其与值连接。
$manu = $manu . $row["TyreMan"] . '[' . $row["countTyreMan"] . ']';