-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblogpage.php
More file actions
102 lines (98 loc) · 4.38 KB
/
blogpage.php
File metadata and controls
102 lines (98 loc) · 4.38 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
include('header.php');
?>
<head>
<title>Blogposts</title>
<link rel="stylesheet" type="text/css" href="css\BlogStyle.css">
<link rel="stylesheet" type="text/css" href="css\style.css">
</head>
<body>
<div class="blogwrapper">
<div class="blogheader">
<h1>Blogposts</h1>
<div class="newadknop">
<a href="newpost"><button href="newpost" class="newadbutton" style="width: 25%;"><i class="fas fa-plus"></i> Blogpost plaatsen</button></a>
</div>
</div>
<div class="blogcontainer">
<div class="filters" style="margin-bottom: 5%">
<h2 style="margin-bottom: 2%">Categorieën</h2>
<div class="checkboxplantsoort">
<label><input type="checkbox" name="cate[]" value="verzorging" onchange="filterBlogposts(this.value)">Verzorging</label><br>
<label><input type="checkbox" name="cate[]" value="speciale evenementen" onchange="filterBlogposts(this.value)">Speciale evenementen</label><br>
<label><input type="checkbox" name="cate[]" value="vieringen en feestdagen" onchange="filterBlogposts(this.value)">Vieringen en feestdagen</label><br>
</div>
</div>
<div class="grid-3-col" id="blogpostGallery">
<?php
require 'includes/dbh.inc.php';
$sql = "SELECT * FROM Blogpost b JOIN User u ON b.blogUserId = u.idUser LEFT JOIN BlogImage bi ON b.idPost = bi.idBlog ORDER BY b.idPost DESC";
$number_of_posts = $result->num_rows;
//array with all blogpost Ids
$allIdPosts = array();
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
//checks if blogpost id already exists in array > if blogpost id exists in array -> skip current blogpost
if(!in_array($row['idPost'], $allIdPosts)){
if(empty($row["imgName"])){
$blogImage = 'images/plantje.png';
} else {
$blogImage = 'uploads/'.$row['imgName'];
}
echo '<div class="blogpost">
<a class="linkPlant" href="bloginfo?idBlog='.$row["idPost"].'">
<div class="blogImage">
<img src="'.$blogImage.'" alt="">
</div>
<div class="blogDescription">
<h2>'.$row["blogTitle"].'</h2>
<h3>'.$row["firstName"].'</h3>
<p class="shortBlogDesc">'.$row["blogDesc"].'</p>
<h4 class="alignleft">'.date_format(date_create($row["blogDate"]),"d-m-Y").'</h4>
<h4 class="alignright">'.$row["blogCategory"].'</h4>
</div>
</a>
</div>';
//add blogpost id to array
array_push($allIdPosts, $row['idPost']);
}
}
} else {
echo "0 resultaten";
}
$conn->close();
?>
</div>
</div>
</div>
</body>
<script>
var allCheckedFilters = [];
function filterBlogposts(value) {
if(!allCheckedFilters.includes(value)){
allCheckedFilters.push(value);
} else {
for(i = 0; i < allCheckedFilters.length; i++) {
if (allCheckedFilters[i] == value) {
allCheckedFilters.splice(i, 1);
break;
}
}
}
$.ajax({
url: "blogFilter.php",
type: 'post',
data: { filters: allCheckedFilters},
success: function(result)
{
document.getElementById("blogpostGallery").innerHTML = result;
}
})
}
</script>
<?php
include('footer.php');
include('feedback.php');
?>