Kod z pliku o nazwie dodaj.php:
<?php include('config.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.&&g/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.&&g/1999/xhtml" lang="pl" xml:lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="Stylesheet" type="text/css" href="style.css"/> </head> <body > <form action="" method="get"> <fieldset> <input type="text" name="drop_1" size="50" list="txtHint" onkeyup="showHint(this.value)"/> <datalist id="txtHint"></datalist><br> <script> function showHint(str) { var xhttp; if (str.length == 0) { document.getElementById("txtHint").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { document.getElementById("txtHint").innerHTML = xhttp.responseText; } }; xhttp.open("GET", "spr.php?drop_var="+str, true); xhttp.send(); } </script> </fieldset> </form> </body>
i drugi plik spr.php
<?php include('config.php'); $drop1p = $_GET['drop_var']; $query = "SELECT * FROM kompresory WHERE nr LIKE '%$drop1p%'"; } ?>
Dane z MySQL:
N10-0585AM
N10-0500AM
N10-0338AM
Z10-0901AM