-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·53 lines (50 loc) · 1.83 KB
/
index.php
File metadata and controls
executable file
·53 lines (50 loc) · 1.83 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
49
50
51
52
53
<?php
require_once 'layout/head.php';
/* Connect to a MySQL database using driver invocation */
$dsn = 'mysql:dbname=iti_malia;host=172.17.0.2;';
$user = 'root';
$password = '123456';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$racas = $dbh->query("SELECT * FROM racas");
?>
<main role="main" class="container">
<div class="starter-template">
<div class="lead" style="margin-top: 100px">
<h2>Raças
<a href="formulario.php" class="btn btn-success">
Cadastrar
</a>
</h2>
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Nome</th>
<th scope="col">Ações</th>
</tr>
</thead>
<tbody>
<?php foreach ($racas->fetchAll() as $raca): ?>
<tr>
<th scope="row"><?= $raca['id'] ?></th>
<td><?= $raca['nome'] ?></td>
<td>
<button type="button" class="btn btn-primary">
Editar
</button>
<button type="button" class="btn btn-danger">
Deletar
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</main><!-- /.container -->
<?php require_once 'layout/footer.php';