Temat: firma1 - Szukaj imie
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>firma1</title>
</head>
<body bgcolor="#eeeeee">
<?php
if (isset($_POST["q"])) $q=$_POST["q"]; else $q="";
?>
<form action="" method="post">
Imie:
<input type="text" name="q" value="<?php echo $q; ?>">
<input type="submit" value="Szukaj">
</form>
<hr>
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td bgcolor=yellow>`id`</td>";
echo "<td bgcolor=yellow>`imie`</td>";
echo "<td bgcolor=yellow>`nazwisko`</td>";
echo "<td bgcolor=yellow>`stanowisko`</td>";
echo "<td bgcolor=yellow>`rok`</td>";
echo "</tr>";
if ($_POST)
{
$co=mysqli_connect("localhost", "root", "", "firma1");
$qu=mysqli_query($co, "SELECT * FROM baza WHERE imie LIKE '%".$q."%';");
$i=0;
while ($re=mysqli_fetch_array($qu))
{
if ($i%2==0) $b="#e3e7e6"; else $b="#ffffff";
echo "<tr>";
echo "<td bgcolor=".$b.">".($re["id"])."</td>";
echo "<td bgcolor=".$b.">".($re["imie"])."</td>";
echo "<td bgcolor=".$b.">".($re["nazwisko"])."</td>";
echo "<td bgcolor=".$b.">".($re["stanowisko"])."</td>";
echo "<td bgcolor=".$b.">".($re["rok"])."</td>";
echo "</tr>";
$i++;
}
mysqli_close($co);
}
echo "</table>";
?>