Skip to content

Instantly share code, notes, and snippets.

Created Oct 14, 2019
What would you like to do?
include_once "database.php";
$statement = $database->query("SELECT * FROM person;");
$people = $statement->fetchAll(PDO::FETCH_OBJ);
<!--We can interpolate HTML and PHP-->
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>People list</title>
table, th, td {
border: 1px solid black;
<th>Fist Name</th>
<th>Last name</th>
we use foreach to repeat <tr>
(look at static_table.html)
<?php foreach ($people as $person) {?>
<td><?php echo $person->id ?></td>
<td><?php echo $person->first_name ?></td>
<td><?php echo $person->last_name ?></td>
<td><?php echo $person->gender ?></td>
<td><a href="<?php echo "edit.php?id=" . $person->id ?>">Edit</a></td>
<td><a href="<?php echo "delete.php?id=" . $person->id ?>">Delete</a></td>
<?php }?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment