<?php // config.php - File containing database connection settings $servername = "localhost"; $username = "root"; $password = ""; $dbname = "mydatabase"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // search.php - File that handles user input and executes SQL query $search_term = $_GET['q']; $query = "SELECT * FROM mytable WHERE name LIKE '%$search_term%'"; $result = $conn->query($query); if ($result->num_rows > 0) { // Output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["name"]. "<br>"; } } else { echo "0 results"; } $conn->close(); ?>