Basically I want create a reset along with search button in my search engine, but I'm stuck at writing that part, here is my code so far:
<html>
<body>
<form action="" method="post">
<input type="text" name="filter">
<input type="submit" value="GO">
</form>
<?php
if(isset($_POST['filter'])){
$sql = "SELECT id, first_name, last_name, sex FROM employee where first_name like '%".$_POST['filter']."%'";
} else {
$sql = "SELECT id, first_name, last_name, sex FROM employee";
}
?>
</body>
</html>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = $conn->query($sql);
if ($result->num_rows > 0) { // output data of each row
echo '<table>';
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td><td>" . $row["first_name"]. "</td><td>" . $row["last_name"]. "</td><td>" . $row["sex"] . "</tr>";
}
echo '</table>';
} else {
echo "0 results";
}
$conn->close();
Where do I create the reset button in? really stuck at that part, please consider help