Zad3.php May 2026
Add an input field that triggers a JavaScript function on every keystroke ( keyup ).
query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo " " . $row["name"] . " "; } } else { echo "No results found"; } $conn->close(); ?> Use code with caution. Copied to clipboard Why this is useful zad3.php
function showResults(str) { if (str.length == 0) { document.getElementById("results").innerHTML = ""; return; } const xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("results").innerHTML = this.responseText; } }; xmlhttp.open("GET", "search.php?q=" + str, true); xmlhttp.send(); } Use code with caution. Copied to clipboard Add an input field that triggers a JavaScript
This example uses a simple database connection to fetch matching names. " "; } } else { echo "No results found"; } $conn->close();
Provides immediate feedback, making it faster to find specific data.