<!-- (A) SEARCH FORM --> <form method="POST" action="\employees.php"> <input type="text" name="search" placeholder="Search..." required> <input type="submit" value="Search"> </form> <?php // (B) PROCESS SEARCH WHEN FORM SUBMITTED if (isset($_POST["search"])) { // (B1) SEARCH FOR USERS require "3-search.php"; // (B2) DISPLAY RESULTS if (count($results) > 0) { foreach ($results as $row) { printf("Name - %s <div> Surname - %s <div> Device - %s </div> " ,$row["Name"], $row["Surname"], $row["ID_Devices"]); echo "<br>"; } } else { echo "No results found"; } } ?>
(A) SEARCH FORM This search form allows a user to search for employee records based on the name of the employee. It sends the search query to itself when submitted (B) PROCESS SEARCH WHEN FORM SUBMITTED This code checks if the search form has been submitted. If it has, it processes the search and displays the results. (B1) SEARCH FOR USERS This code searches the employees database for records that match the search query. (B2) DISPLAY RESULTS This code loops through the results and displays them in a table.