Tutorial de MySQL [Partea 8]
Exemplu: cautare generala folosind LIKE si caracterul % si la inceput si la sfarsit
/* urmeaza fisierul cautare2.html */
<html>
<head><title>Cautare 2</title>
</head>
<body>
<b>Cautare inregistrari</b>
<form method="POST" action="where2.php">
Numele cautat: <input type="text" name="nume1"><br>
<input type="submit" value="Trimite">
</form>
</body>
</html>
<html>
<head><title>Cautare 2</title>
</head>
<body>
<b>Cautare inregistrari</b>
<form method="POST" action="where2.php">
Numele cautat: <input type="text" name="nume1"><br>
<input type="submit" value="Trimite">
</form>
</body>
</html>
/* urmeaza fisierul where2.php */
<?php
include "conexiune.php";
$nume1=$_POST['nume1'];
$sql=mysql_query("SELECT * FROM proba WHERE nume LIKE '%$nume1%'");
echo "<table border=1>";
echo "<tr><td>ID</td><td>Nume</td><td>Prenume</td></tr>";
while ($row=mysql_fetch_row($sql)) {
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";
}
echo "</table>";
mysql_close($conexiune);
?>