我有一个页面从我的mysql数据库加载数据并正确显示数据,但在尝试实现搜索功能后,现在尝试加载页面时出错。
下面是我为搜索栏添加的html代码(这是在PhysicianSearch.php文件中):
<form action="PhysicianSearch.php" method="post">
<input type="text" placeholder="Search.." name="ValueToSearch">
<input type="submit" name="search" value="Filter"><br><br>
</form>
下面是我为搜索栏添加的php代码(这是在PhysicianSearch.php文件中):
<?php
if(isset($_POST['search'])) {
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM Physician WHERE CONCAT('physicianID', 'firstName', 'lastName', 'yearNum', 'yearNum', 'position', 'isAttending', 'highRiskTrained') LIKE '%" . $valueToSearch ."%'";
$search_result = filterTable($query);
} else {
$query = "select * from Physician";
$search_result = filterTable($query);
}
function filterTable($query) {
$connect = mysqli_connect("localhost", "root", "password", "dbName");
$filter_results = mysqli_query($connect, $query);
return $filter_results
}
?>
答案 0 :(得分:1)
您的input
名称为ValueToSearch
,其中PHP代码正在检查valueToSearch
确保他们有相同的案例