-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
67 lines (50 loc) · 1.47 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
ini_set('display_errors', '1');
$user = 'root';
$password = '52752';
$filtro = '';
if (isset($_GET['filtro'])) {
$filtro = $_GET['filtro'];
}
$conexion = mysqli_connect('localhost', $user, $password, 'e-coomerce-prueba');
$resultadoConsulta = mysqli_query($conexion, "select * from usuarios where name like '%$filtro%'");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Filtrar</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>listado de personas</h1>
<section class="input-filter">
<form method="get">
<div>
<input type="text" name="filtro" placeholder="Filtro" value="<?=$filtro ?? ''?>">
<button type="submit">Filtrar</button>
</div>
</section>
</form>
<section class="filter">
<table >
<tr>
<th>Nombre</th>
<th>Apellido</th>
</tr>
<?php
while ($fila = mysqli_fetch_array($resultadoConsulta)) {
$nombre = $fila['name'];
$username = $fila['username'];
echo "<tr>";
echo "<td>$nombre</td>";
echo "<td>$username</td>";
echo "<tr>";
}
?>
</table>
</section>
</body>
</html>