Created
February 12, 2018 23:03
-
-
Save parzibyte/8462077d72de9c02fd927ffd1c4ebd87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> | |
</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> | |
</tr> | |
<?php } ?> | |
</tbody> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment