-
Notifications
You must be signed in to change notification settings - Fork 1
/
php-photo-grid.php
82 lines (68 loc) · 1.8 KB
/
php-photo-grid.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<style>
body {
padding: 2rem;
}
.gallery-wrapper {
display: grid;
grid-template-columns: 1fr;
grid-gap: 2rem;
max-width: 1100px;
margin: auto;
}
@media (min-width: 600px) {
.gallery-wrapper {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 2rem;
}
}
@media (min-width: 900px) {
.gallery-wrapper {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 2rem;
}
}
.gallery-image img {
width: 100%;
}
</style>
<?php
//index.php
$connect = mysqli_connect("localhost", "id4055259_karel", "karel", "id4055259_slider");
function make_query($connect)
{
//$query = "SELECT * FROM banner ORDER BY banner_id ASC"; //originele query
//$query = "SELECT * FROM banner ORDER BY banner_id ASC LIMIT 4";
$query = "SELECT * FROM banner WHERE banner_tag='winter' ORDER BY banner_id ASC"; //query met selectie voor winter
$result = mysqli_query($connect, $query);
return $result;
}
function make_photolist($connect)
{
$output = '';
$result = make_query($connect);
while($row = mysqli_fetch_array($result))
{
$output .= '
<div class="gallery-image">
<a href=' . $row["banner_url"] . '><img src="banner/'.$row["banner_image"].'" alt="'.$row["banner_title"].'"/></a>
</div>'
;
}
return $output;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>How to Make Dynamic Bootstrap Carousel with PHP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="gallery-wrapper"><?php echo make_photolist($connect); ?></div>
<!-- <div class="g1"></div>-->
</body>
</html>