gpt4 book ai didi

php - 在我的搜索中出现错误 (php)

转载 作者:太空宇宙 更新时间:2023-11-03 10:37:21 25 4
gpt4 key购买 nike

我正在创建一个搜索字段以从表中搜索 idfirstnamelastnameemail 注册但出现错误:

Notice: Undefined variable: valuetosearch in D:\Xampp\htdocs\Registration_system\dashboard.php on line 13

Notice: Undefined variable: query in D:\Xampp\htdocs\Registration_system\dashboard.php on line 14

Warning: mysqli_query(): Empty query in D:\Xampp\htdocs\Registration_system\dashboard.php on line 27

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\Xampp\htdocs\Registration_system\dashboard.php on line 61

<style type="text/css">

table, tr, th, td
{

border: 1px solid black;
}
</style>
<?php

if (isset($_POST['valuetosearch'])) {
$valuetosearch =$_POST['valuetosearch'];
$valuetosearch = "SELECT * FROM `registration` WHERE CONCAT(`firstname`, `lastname`, `email`, `phonenumber`) LIKE '%".$valuetosearch."'";
$search_result= filtertable($query);
}

else
{
$query= "SELECT * FROM `registration`";
$search_result= filtertable($query);

}

function filtertable($query){

require_once'config.php';
$filter_result= mysqli_query($CONN, $query);
return $filter_result;

}
?>


<h1>Welcome on dashboard </h1>
<ul>
<li><a href="dashboard.php">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="dashboard.php">Profile</a></li>
<li><a href="login.php">Logout</a></li>
</ul>

<form action="dashboard.php" method="POST">

<input type="text" name="valuetosearch" placeholder="Search here...">
<input type="submit" name="search" value="submit"> <br><br>

<table>

<tr>

<th>id</th>
<th>First name</th>
<th>Last name</th>
<th>email</th>
<th>Phone number</th>

</tr>
<?php while($row= mysqli_fetch_array($search_result)): ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['firstname']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<td><?php echo $row['email']; ?></td>

</tr>

<?php endwhile; ?>
</table>

</form>

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