gpt4 book ai didi

php - 使用数组查询数据库

转载 作者:行者123 更新时间:2023-11-29 02:06:29 24 4
gpt4 key购买 nike

<分区>

我正在尝试使用数组查询我的数据库,我正在尝试计算数据库中每个国家/地区的查询返回的行数,并计算这些国家/地区中每个国家/地区的行数等于1. 使用以下代码:

<?php

include ('mysqli_connect.php'); // indclude mysql connection functions

$countries = array('united states','canada','united kingdom');

foreach($countries as $country){
//e.g. $r_spain holds the results from the query below with spain as $country
$r_.$country = mysqli_query($dbc,"SELECT * FROM feelings WHERE country = '$country' AND digit='1'");

//loop through the results
while($row = mysqli_fetch_array($r_.$country, MYSQLI_ASSOC)){
$rowCount = mysqli_num_rows($r_.$country);
echo $country."=".$rowCount;
}
}

?>

这是我收到的错误信息:

Catchable fatal error: Object of classmysqli_result could not be convertedto string in/home2/designwr/public_html/uwe/notalone/updates/percentage.phpon line 9

谁能指出我正确的方向?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com