<?php
session_start();
require_once 'includes/dbh-posts.inc.php';
require_once 'includes/functions.inc.php';
$results_per_page = 6;
$sql='SELECT * FROM posts';
$result = mysqli_query($conn, $sql);
$number_of_results = mysqli_num_rows($result);
$number_of_pages = ceil($number_of_results/$results_per_page);
if(!isset($_GET['page'])) {
$page = 1;
header("Location: index.php?page=" . $page);
}
else if(empty($_GET['page'])){
$page = 1;
header("Location: index.php?page=" . $page);
}
else if($_GET['page'] > $number_of_pages)
{
$page = 1;
header("Location: index.php?page=" . $page);
}
else {
$page = $_GET['page'];
}
$this_page_first_result = ($page-1)*$results_per_page;
?>
<!DOCTYPE HTML>
<html>
<head>
<title>De Wandelmannen</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper" class="fade-in">
<!-- Intro -->
<div id="intro">
<h1>De Wandel<br>mannen</h1>
<p>Welkom bij de blog van Sjef en Ben. <br>
Dit jaar hebben wij de camino de Santiago de Compostela gelopen. <br>
En dit is ons avontuur!</p>
<ul class="actions">
<li><a href="#header" class="button icon solid solo fa-arrow-down scrolly">Continue</a></li>
</ul>
</div>
<!-- Header -->
<header id="header">
<a href="index.php" class="logo">De Wandelmannen</a>
</header>
<!-- Nav -->
<nav id="nav">
<ul class="links">
<li class="active"><a href="index.php">Home</a></li>
<li><a href="about.php">Over ons</a></li>
</ul>
<ul class="icons">
<li><a href="http://facebook.com" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
<li><a href="http://princeepartyservice.nl" class="icon solid fa-globe"><span class="label">Website</span></a></li>
<li><a href="login.php" class="icon regular fa-user"><span class="label">Login</span></a></li>
</ul>
</nav>
<!-- Main -->
<div id="main">
<!-- Featured Post -->
<?php
if($_GET['page'] == 1)
{
echo '<article class="post featured">
<header class="major" style="margin: 0;">
<h2>Welkom bij de Wandelmannen!</h2>
<p>Dit is de blogwebsite van Sjef en Ben. Wij gaan volgend jaar de camino de
Santiago de Compostela lopen, en dat avontuur kan je live volgen op deze blog!
Als je een post wilt maken, <a href="login.php">log dan in.</a> Zo niet, begin dan vooral
hieronder te lezen, en geniet mee van het avontuur!</p>
</header>
</article>';
}
?>
<!-- Posts -->
<section class="posts">
<?php
$this_page_first_result = ($page-1)*$results_per_page;
$sql1 = 'SELECT * FROM posts ORDER BY `id` DESC LIMIT ' . $this_page_first_result . ',' . $results_per_page;
$result1 = mysqli_query($conn, $sql1);
$array = array();
while($row = mysqli_fetch_assoc($result1))
{
$array[] = $row;
}
foreach($array as $key => $value)
{
echo
'<article>
<header>
<span class="date">' .$array[$key]['dateCreated'] .'</span>
<h2>'. $array[$key]['title'] . '</h2>
</header>';
if(!empty($array[$key]['pathToImage']))
{
echo '<a href="post.php?postId='. $array[$key]['id'] .'" class="image fit"><img src="uploads/images/'. chopStringToImageName($array[$key]['pathToImage']) .'" alt="" /></a>';
}
echo
'<p style="word-wrap: break-word; text-align: center">' . $array[$key]['description'] .'</p>
<ul class="actions special">
<li><a href="post.php?postId='. $array[$key]['id'] .'" class="button">Lees verder</a></li>
</ul>
</article>';
}
?>
</section>
<!-- Footer -->
<footer>
<div class="pagination">
<?php
for($page=1; $page<=$number_of_pages; $page++)
{
if(isset($_GET['page']) && $_GET['page'] == $page)
{
echo '<a href="index.php?page='. $page . '" class="page active">'. $page .' </a>';
}
else
{
echo '<a href="index.php?page='. $page . '">'. $page .' </a>';
}
}
?>
</div>
</footer>
</div>
<!-- Footer -->
<footer id="footer">
</footer>
<!-- Copyright -->
<div id="copyright">
<ul><li>Mede mogelijk gemaakt door Princee Partyservice</li></li></ul>
</div>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>