-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (42 loc) · 1.69 KB
/
index.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
<?php
include('config/db_connect.php');
// write query for all objects
$sql = 'SELECT title, ingredients, id FROM pizzas ORDER BY created_at';
// make query and get results
$result = mysqli_query($conn, $sql);
// fetch the resulting rows as an array
$pizzas = mysqli_fetch_all($result, MYSQLI_ASSOC);
// free result from memory
mysqli_free_result($result);
// close connection
mysqli_close($conn);
// explode(',', $pizzas[0]['ingredients']);
?>
<!DOCTYPE html>
<html>
<?php include 'templates/header.php'; ?>
<h4 class="center grey-text">Pizzas</h4>
<div class="container">
<div class="row">
<?php foreach($pizzas as $pizza) : ?>
<div class="col s6 md3">
<div class="card z-depth-0">
<img src="img/pizza.svg" alt="" class="pizza">
<div class="card-content center">
<h6><?php echo htmlspecialchars($pizza['title']); ?></h6>
<ul>
<?php foreach(explode(',', $pizza['ingredients']) as $ing) : ?>
<li><?php echo htmlspecialchars($ing); ?></li>
<?php endforeach; // foreach ingredients ?>
</ul>
</div>
<div class="card-action right-align">
<a href="details.php?id=<?php echo $pizza['id']; ?>" class="brand-text">more info</a>
</div>
</div>
</div>
<?php endforeach; // foreach pizzas ?>
</div>
</div>
<?php include 'templates/footer.php'; ?>
</html>