Zad3.php (2026)

This example uses a simple database connection to fetch matching names.

Create a script (e.g., search.php ) that receives the search term via a GET or POST request. 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 This example uses a simple database connection to

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 Copied to clipboard query($sql); if ($result->num_rows > 0)

Reduces server load by only fetching specific data instead of loading an entire list.

Powered by atecplugins.com