I've created the "Customers' Information" in the database. I also put and view it on my customers.php page. Help me to make some "Search box" inside the page. The search box will only search and view what keyword nearer in my database table.
Example: When I search "Jenny" the result of search box will be all "Jenny" in my database table. When my search box don't find "Jenny," the search box will say "no results found"
Here is my code in customers.php
<?php
$conn = mysqli_connect('localhost','root','','newcartdb');
if(mysqli_connect_errno()){
echo 'Failed to Connect: '.mysqli_connect_error();
}
if(isset($_POST['delete'])){
$DeleteQuery = "DELETE FROM customers WHERE id='$_POST[hidden]'";
mysqli_query($conn,$DeleteQuery);
}
$query = "SELECT * FROM customers ORDER BY id ASC";
$results = mysqli_query($conn,$query);
echo '<table class="table table-bordered">
<thead>
<tr>
<th width="40px">ID</th>
<th>Email</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Gender</th>
<th>Titlename</th>
<th>BirthMonth</th>
<th>BirthDay</th>
<th>BirthYear</th>
<th>Cellphone Number</th>
<th>Phone Number</th>
<th>Address1</th>
<th>Address2</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>';
while($userData = mysqli_fetch_array($results)){
echo '<form action="customers.php" method="POST">';
echo '<tr>';
echo '<td>'.$userData['id'].'</td>';
echo '<td>'.$userData['Email'].'</td>';
echo '<td>'.$userData['Firstname'].'</td>';
echo '<td>'.$userData['Lastname'].'</td>';
echo '<td>'.$userData['Gender'].'</td>';
echo '<td>'.$userData['Titlename'].'</td>';
echo '<td>'.$userData['BirthMonth'].'</td>';
echo '<td>'.$userData['BirthDay'].'</td>';
echo '<td>'.$userData['BirthYear'].'</td>';
echo '<td>'.$userData['CellphoneNumber'].'</td>';
echo '<td>'.$userData['PhoneNumber'].'</td>';
echo '<td>'.$userData['Address1'].'</td>';
echo '<td>'.$userData['Address2'].'</td>';
echo '<td><input type="hidden" name="hidden" value="'.$userData['id'].'">';
echo '<td><input type="submit" name="delete" value="Delete" class="btn btn-info" / ></td>';
echo '</tr>';
echo '</form>';
}
echo '</table>';
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…