我是 mysqli 的新手,并且在使用 mysqli 循环遍历结果时遇到问题。不幸的是,我只得到一个结果。当我将查询放入 phpMyAdmin 时,它会产生三个结果。我相信相关代码在这里,我只是说错了:
$connection = new mysqli($host, $databaseUsername, $databasePassword, $database);
if ($connection->connect_errno > 0) {
die ('Unable to connect to database [' . $connection->connect_error . ']');
}
$sql = "SELECT clientId, studentFirstName, studentLastName
FROM clients
WHERE (studentEmail = '$postEmail') OR (parentEmail = '$postEmail');";
if (!$result = $connection->query($sql)) {
die ('There was an error running query[' . $connection->error . ']');
}
echo '<select class = "toolbarDropdown" id = "toolbarDropdown-MultipleAccounts">';
while ($row = $result->fetch_array()) {
echo '<option value="'.$row["clientId"].'">'.$row["studentFirstName"].' '.$row["studentLastName"].'</option>';
}
echo '</select>';