<?php
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
$poID=$_POST['poID'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM user
INNER JOIN tb_position on user.poID=tb_position.poID WHERE poID LIKE '%".$poID."%'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM user
INNER JOIN tb_position on user.poID=tb_position.poID";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
include "connect.php";
$filter_Result = mysqli_query($conn, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP HTML TABLE DATA SEARCH</title>
<style>
table,tr,th,td
{
border: 1px solid black;
}
</style>
</head>
<body>
<form action="search.php" method="post">
<select name="poID'" id="poID">
<option>- ตำแหน่ง -</option>
<?PHP
include"connect.php";
$sql="SELECT * FROM tb_position ";
$dbquery = $conn->query($sql);
while($result = $dbquery->fetch_assoc())
{
?>
<option value="<?=$_POST['poID'];?>"><?=$result['detail'];?>
</option>
<?PHP }?>
</select>
<input type="submit" name="search" value="Filter"><br><br>
<table>
<tr>
<th>ชื่อ</th>
<th>นามสกุล</th>
<th>ตำแหน่ง</th>
</tr>
<!-- populate table from mysql database -->
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['surname'];?></td>
<td><?php echo $row['detail'];?></td>
</tr>
<?php endwhile;?>
</table>
</form>
</body>
</html>
เมื่อกดคำว่า fitterไปแล้ว มันขึ้น เออเร่อแบบนี้ค่ะ : Undefined index: poID in D:\xampp\htdocs\test\pages\search.php on line 6
ไม่ทราขว่าแก้ไขยังไงอ่ะคะ