[英]MYSQL Query Error (Result Array)
I have this result 我有这个结果
Furni Count: Array
My code is 我的代码是
$query2 = mysql_query(
"SELECT COUNT(DISTINCT id) FROM items
WHERE base_item='" . $weekly2['furniture_id'] . "'"
);
$OwnerCount = mysql_fetch_array($query2);
echo "<tr><td width=\"92%\" >Owner Count: $OwnerCount<form><input type=\"submit\" value=\"Owner Last Online\"></form></td></tr>";
It's because your echo
ing an array, try print_r($Ownercount);
这是因为您
echo
了一个数组,所以请尝试print_r($Ownercount);
and you should see the array (and the keys). 并且您应该看到数组(和键)。
Example: 例:
echo $Ownercount[0];
Should return the first key in the array (which is probably what you want). 应该返回数组中的第一个键(可能是您想要的)。
you can put an alias on the query, like this : 您可以在查询上放置一个别名,如下所示:
COUNT(DISTINCT id) as total
and then call 然后打电话
$Ownercount["total"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.