我希望能够选择值与我在php中调用的值匹配的所有行 这就是我现在拥有的,唯一得到的是第一行。没有其他行。
<?php>
session_start();
require "db.inc.php";
$id = $_SESSION['userId'];
$sql = "SELECT followingId FROM following WHERE followerId=$id";
$sth = $conn->query($sql);
if(!$sth) {
echo("Error description: " . mysqli_error($conn));
die();
}
$result = mysqli_fetch_array($sth);
echo var_dump($result);
$followedId = $result['followingId'];
echo $followedId;
$ conn是db.inc.php中的连接变量
答案 0 :(得分:1)
您必须遍历要获取的结果数组
while ($row = mysqli_fetch_array($result)) {
foreach($row as $field => $value) {
//do something with $field and $val
}
}