-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistarPersonas.php
More file actions
48 lines (48 loc) · 1.16 KB
/
listarPersonas.php
File metadata and controls
48 lines (48 loc) · 1.16 KB
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
<?php
include_once "base_de_datos.php";
$sentencia = $base_de_datos->query("SELECT * FROM personas;");
$personas = $sentencia->fetchAll(PDO::FETCH_OBJ);
?>
<!--Recordemos que podemos intercambiar HTML y PHP como queramos-->
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Tabla de ejemplo</title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Género</th>
<th>Editar</th>
<th>Eliminar</th>
</tr>
</thead>
<tbody>
<!--
Atención aquí, sólo esto cambiará
Pd: no ignores las llaves de inicio y cierre {}
-->
<?php foreach($personas as $persona){ ?>
<tr>
<td><?php echo $persona->id ?></td>
<td><?php echo $persona->nombre ?></td>
<td><?php echo $persona->apellidos ?></td>
<td><?php echo $persona->sexo ?></td>
<td><a href="<?php echo "editar.php?id=" . $persona->id?>">Editar</a></td>
<td><a href="<?php echo "eliminar.php?id=" . $persona->id?>">Eliminar</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</body>
</html>