Php 带有for循环和数组的sql查询
我有一个for循环,用于多次执行语法:Php 带有for循环和数组的sql查询,php,arrays,for-loop,Php,Arrays,For Loop,我有一个for循环,用于多次执行语法: for ($c=1; $c<=$rowCount; $c++){ $reas[$c-1]=$_SESSION["reas".$c]; $exp[$c-1]=$conn->query("SELECT reason_exp from rehab_reasons where reason_name='".$reas[$c-1]."'"); } 现在我想用for循环来回显它 for ($x=0; $x<$rowCount; $
for ($c=1; $c<=$rowCount; $c++){
$reas[$c-1]=$_SESSION["reas".$c];
$exp[$c-1]=$conn->query("SELECT reason_exp from rehab_reasons where reason_name='".$reas[$c-1]."'");
}
现在我想用for循环来回显它
for ($x=0; $x<$rowCount; $x++){
$text=$act[$x].' was given to '.$conj[$x].' '.$reas[$x].' '.$exp[$x]['reason_exp'];
}
它似乎不起作用。。我想做的是:
$exp[0]=来自数据库的reason\u exp,其中reason\u name=$reas[0]
$exp[1]=数据库中的reason\u exp,其中reason\u name=$reas[1]
...
等等
我的语法有什么问题 试试看
$text=$act[$x].' was given to '.$conj[$x].' '.$reas[$x].' '.($exp[$x]['reason_exp']);
仍然出现以下错误:致命错误:无法将mysqli_result类型的对象用作数组