1 回答
TA贡献1818条经验 获得超11个赞
绑定到查询的变量未初始化。$id
您想要搜索“名字”,因此您需要在查询中使用变量$firstname。
// Check if formular is send and $_POST['firstname'] is set
if (isset($_POST['firstname'])) {
// Escaping is not neccessary because you use prepared statements!
$firstname = $_POST['firstname'];
$sql = "SELECT * FROM usersthree WHERE firstname=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $firstname);
$result = $stmt->get_result(); // get the mysqli result
$queryResult = mysqli_num_rows($result);
if ($queryResult > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<div>
<p>".$row['name']."<p>
<p>".$row['email']."<p>
</div>";
}
} else {
echo "No users with name $firstname!";
}
}
- 1 回答
- 0 关注
- 70 浏览
添加回答
举报