Skip to content

Instantly share code, notes, and snippets.

@sebgates
Last active August 20, 2017 07:05
Show Gist options
  • Save sebgates/645bbbc1f7d19047f5309c4677d87955 to your computer and use it in GitHub Desktop.
Save sebgates/645bbbc1f7d19047f5309c4677d87955 to your computer and use it in GitHub Desktop.
<?php
require_once('includes/db_connect.php');
include 'includes/header.php';
?>
<!-- Page Content -->
<body>
<div class="container"> <!--start container-->
<div class="row"><!--wrap both columns in a row-->
<div class="col-md-8"><!--blog entries column-->
<?php
//This prepared statement will 'prepare' the database for query to be run then when $statementt->execute is run. The items from the array will be bound and sent to the server.
$statement = $db->prepare('SELECT postID, postTitle, postCont, postDate FROM blog_posts WHERE postID = :postID');
$statement->execute(array(':postID' => $_GET['id']));
$row = $statement->fetch();
//If there is no postID coming from the database, their is no record so redirect the user to the index page.
if($row['postID'] == ''){
header('Location: ./');
exit;
}
//Display the select post in full:
echo '<div>';
echo '<img class="card-img-top img-fluid extra-margin-bottom" src="http://placehold.it/750x300" alt="Card image cap">';
echo '<h1>'.$row['postTitle'].'</h1>';
echo '<p>Posted on '.date('jS M Y', strtotime($row['postDate'])).'</p>';
echo '<p>'.$row['postCont'].'</p>';
echo '</div>';
?>
<!-- Start Comments -->
<div id="disqus_thread"></div>
<script>
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://myblog-8xojxxepw6.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div><!-- end blog entries column -->
<!-- Sidebar Widgets Column -->
<?php
include 'includes/sidebar.php';
?>
</div> <!-- End Row -->
</div> <!-- End Container -->
<?php
include 'includes/footer.php';
?>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment