gpt4 book ai didi

php - IF Else 变量问题

转载 作者:行者123 更新时间:2023-11-29 21:28:18 26 4
gpt4 key购买 nike

我的两个 IF ELSE 语句出现错误,但第三个没有出现问题。

注意:尝试获取employees2.php第51行非对象的属性0 个结果

// Pass appropriate SQL to the database
$lname = htmlspecialchars($_POST["lname"]);
$fname = htmlspecialchars($_POST["fname"]);
$empid = htmlspecialchars($_POST["empid"]);

echo "<h3>Search results.</h3>";
$sqlL = "SELECT * FROM employees WHERE LAST_NAME = \"" . $lname . "\"";
$sqlF = "SELECT * FROM employees WHERE FIRST_NAME \"" . $fname . "\"";
$sqlID = "SELECT * FROM employees WHERE EMPLOYEE_ID \"" . $empid . "\"";
$resultL = $conn->query($sqlL);
$resultF = $conn->query($sqlF);
$resultID = $conn->query($sqlID);

if ($resultF->num_rows > 0) {
// Output data of each row
printf("\n\t<table><th>Name</th>
<th>Employee ID</th>
");
while ($row = $resultF->fetch_assoc()) {
printf("\n\t<tr><td>%s%s</td>
<td>%s</td></tr>",
$row["LAST_NAME"], $row["FIRST_NAME"], $row["EMPLOYEE_ID"]);
}

echo "</table>\n";
echo "<h5><strong>($resultF->num_rows) results returned.</strong></h5><br>";
} else {
echo "0 results ";
}

最佳答案

尝试while ($row = mysql_fetch_assoc($resultF))

关于php - IF Else 变量问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35401546/

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