저는 여기에 새로운데 페이지에 표시하지 않고 데이터를 필터링하는 데 문제가 있습니다. 오류가 발생하여 도와주세요. 나쁜 영어에 대해 유감스럽게 생각합니다.데이터 필터링 오류가 발생했습니다.
오류 : 페이지가로드 if(isset($_POST['submit']))
이 거짓 일 때 때문에이 오류가 발생하는
Notice: Undefined variable: search_result in /storage/ssd3/688/2645688/public_html/test.php on line
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /storage/ssd3/688/2645688/public_html/test.php on line
<?php
if(isset($_POST['submit']))
{
$valueToSearch = $_POST['search'];
$query = "SELECT * FROM `login` WHERE CONCAT(`id`, `username`, `password`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
}
function filterTable($query)
{
$connect= mysqli_connect("localhost","root","","cable");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<form action="test.php" method="POST">
<div class="container">
\t <div class="row">
<br><br><div class="search">
<input type="text" name="search" class="form-control input-sm" maxlength="64" placeholder="Search" />
<button type="submit" name="submit" class="btn btn-primary btn-sm">Search</button>
</div>
\t </div>
</div>
</br></br>
</form>
<table>
<tr>
<th>Id<br></th>
<th>Username:</th>
<th>Password</th>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['id'];?><br></td>
<td><?php echo $row['username'];?></td>
<td><?php echo $row['password'];?></td>
</tr>
<?php endwhile;?>
</table>
가 없을 수 있습니다 상단에있는 기능을 넣어 것을 염두에 보관해야합니다. 친절하게 $ connect를 filterTable ($ connect, $ query)에 추가하십시오. –