这是我的小脚本
$item="Inception";
$query="SELECT * FROM items WHERE item = '{$item}' LIMIT 1";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$item_id = $row['items_id'];
}
$sql="SELECT AVG(rating) AS AverageRating FROM ratings WHERE item_id = '{$item_id}'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
print(json_encode($row));
输出是这样的:
{"0":"4.5","AverageRating":"4.5"}
我的问题是:行“0”来自哪里?这是正常的吗?