我试图通过循环遍历数组的值 - (称为列)来进行一系列mysqli查询 - 但是没有返回任何内容。
for ($i = 0; $i < sizeof($column); $i++)
{
$mutualInterests = mysqli_query ($conn, "SELECT USER_1 FROM INTERESTS WHERE answer = " . $column[$i] );
while ($row = mysqli_fetch_array ($mutualInterests))
{
echo " $row[USER_1]";
}
}
答案 0 :(得分:-1)
替换它:
while ($row = mysqli_fetch_array ($mutualInterests))
{
echo " $row[USER_1]";
}
用这个:
$count = 0;
while ($row = mysqli_fetch_array ($mutualInterests))
{
echo $row[$count]."<br>";
$count++;
}
让我知道它现在是否有效! :)
答案 1 :(得分:-1)
只需用以下内容替换您给定的代码,然后查看结果..........
$query='SELECT USER_1 FROM INTERESTS WHERE answer ="'.$column[0].'"';
for ($i = 1; $i < sizeof($column); $i++)
{
$query.=' OR answer ="'.$column[$i].'"';
}
$mutualInterests = mysqli_query ($conn,$query);
while ($row = mysqli_fetch_array ($mutualInterests))
{
echo " $row[USER_1]";
}