Dynamic Blog with PHP and MySQL – Front View

Dynamic blog front view shows you major things are a list of all posts, post inner page, categories page, and archives page. Before starting work on the front view you need to add a config.php file that only connects the database and show you the information from the database. Below you have all the detailed information about the dynamic blog front view section.
To see the Dynamic Blog Dashboard Click here
config.php
Connection authentication for the database. Also, set the timezone this help to get country based time as of now I entered “America/Los_Angeles”, based on this time location the articles update post time and date.
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 |
<?php ob_start(); session_start(); //database credentials define('db_host','localhost'); define('db_user','root'); define('db_pass',''); define('db_name','secure_blog'); $db = new PDO("mysql:host=".db_host.";port=8889;dbname=".db_name, db_user, db_pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //set timezone date_default_timezone_set('America/Los_Angeles'); //load classes as needed function __autoload($class) { $class = strtolower($class); //if call from within assets adjust the path $classpath = 'sa_core/class.'.$class . '.php'; if ( file_exists($classpath)) { require_once $classpath; } //if call from within admin adjust the path $classpath = '../sa_core/class.'.$class . '.php'; if ( file_exists($classpath)) { require_once $classpath; } //if call from within admin adjust the path $classpath = '../../sa_core/class.'.$class . '.php'; if ( file_exists($classpath)) { require_once $classpath; } } $user = new User($db); include('functions.php'); ?> |
functions.php
In the functions.php you have core things that help you to remove unwanted characters also translate the country base language.
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 |
<?php function slug($text){ // Replace non letter or digits by - $text = preg_replace('~[^\\pL\d]+~u', '-', $text); // Trim $text = trim($text, '-'); // Translate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // Lowercase $text = strtolower($text); // Remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; } ?> |
index.php
Home page contains all the articles information which only leads to other pages. Pagination helps a lot because here you can add more articles much as you can. By default, the home page creates SEO friendly by URL and other Metadata.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
<?php require('includes/config.php'); ?> <!DOCTYPE html> <html> <head> <title>softAOX - Blog</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name='keywords' content='softaox, blog, dynmaic blog, create blog in php, mysql blog'> <meta name='description' content='softaox blog dynamic creation for post'> <meta name='copyright' content='softAOX'> <meta name='language' content='en'> <meta name='robots' content='index,follow'> <!--css--> <link href="assets/css/master.css" rel="stylesheet" type="text/css"> <!--jquery--> <link rel="icon" type="image/png" href="assets/images/favicon.ico" sizes="16x16"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="assets/js/general.js" type="text/javascript"></script> </head> <body class="bg"> <div class="top-line"> </div> <!--end of line--> <div class="top-bar"> <div class="logo"> <a href="./"><img src="assets/images/softaox_blog.svg" /></a> </div> <!--end of logo--> <?php include ('includes/navbar.php'); ?> <!--end navbar --> </div> <!--end of top bar--> <div class="all-container"> <div class="row nopadding"> <div class="col-md-12 nopadding"> <div class="col-md-7 nopadding"> <div class="blog-listing"> <?php try { $pages = new Paginator('4','p'); $stmt = $db->query('SELECT postID FROM sa_posts'); //pass number of records to $pages->set_total($stmt->rowCount()); $stmt = $db->query('SELECT * FROM sa_posts ORDER BY postID DESC '.$pages->get_limit()); while($row = $stmt->fetch()){ echo '<div class="blog-listing-one">'; echo '<h2><a href="'.$row['postSlug'].'">'.$row['postTitle'].'</a></h2>'; echo '<div class="blog-listing-one-img">'; echo '<a href="'.$row['postSlug'].'"><img src="admin/uploads/'.$row['image'].'" width="100%"></a>'; echo '</div>'; echo'<div class="blog-listing-one-like-bookmark">'; echo '<ul>'; echo '<li><i class="fa fa-calendar" aria-hidden="true"></i><span> On:</span> '.date('jS M Y', strtotime($row['postDate'])).'</li>'; $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM sa_categories, sa_post_categories WHERE sa_categories.catID = sa_post_categories.catID AND sa_post_categories.postID = :postID'); $stmt2->execute(array(':postID' => $row['postID'])); $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC); $links = array(); foreach ($catRow as $cat) { $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>"; } echo '<li><i class="fa fa-folder-open"></i><span> Category: </span>'.implode(", ", $links).'</li>'; echo '</ul>'; echo '</div>'; echo '<p>'.$row['postDesc'].'</p>'; echo '<a href="'.$row['postSlug'].'" class="btn-readmore">Continue Reading</a>'; echo '</div>'; } echo $pages->page_links(); } catch(PDOException $e) { echo $e->getMessage(); } ?> </div> <!--end of blog listing--> </div> <!--end of col-md-7--> <div class="col-md-5 nopadding padding-left"> <div id='sidebar'> <?php require('sidebar.php'); ?> </div> </div> <!--end of col-05--> </div> <!--end of col-md-12--> </div> <!--end of row--> </div> <!--end of all container--> <?php include ('includes/footer.php'); ?> <!--end of footer--> </body> </html> |
sidebar.php
Sidebar section is helpful to see the recent post from the articles.
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 |
<div class="right-box sidebar"> <!--end of search--> <div class="right-card latest"> <div class="head"> <h4>Recent Posts</h4> </div> <!--end of head--> <div class="blog-listing-one blog-listing-one-latest"> <?php $stmt = $db->query('SELECT * FROM sa_posts ORDER BY postID DESC LIMIT 5'); while($row = $stmt->fetch()){ echo '<div class="well">'; echo '<div class="media">'; echo '<a class="pull-left" href="'.$row['postSlug'].'">'; echo '<img class="media-object" src="admin/uploads/'.$row['image'].'" width="100%">'; echo '</a>'; echo '<div class="media-body">'; $string = $row['postTitle']; if (strlen($string) > 80) { $trimhead = substr($string, 0, 80); } else { $trimhead = $string; } echo '<h4 class="media-heading"><a href="'.$row['postSlug'].'">'.$trimhead.'</a></h4>'; echo '<ul class="list-inline list-unstyled">'; echo '<li> <span><i class="fa fa-calendar" aria-hidden="true"></i> '.date('M jS Y', strtotime($row['postDate'])).'</span> </li>'; echo '</ul>'; echo '</div>'; echo '</div>'; echo '</div>'; } ?> </div> </div> <!--Start of Catgories--> <div class="right-card latest"> <div class="head"> <h4>Catgories</h4> </div> <!--Start of List--> <div class="panel panel-info"> <ul class="list-group"> <?php $stmt = $db->query('SELECT catTitle, catSlug FROM sa_categories ORDER BY catID DESC'); while($row = $stmt->fetch()){ echo '<a href="c-'.$row['catSlug'].'" class="list-group-item">'.$row['catTitle'].'</a>'; } ?> </ul> </div> </div> <!--Archives of Catgories--> <div class="right-card latest"> <div class="head"> <h4>Archives</h4> </div> <!--Start of List--> <div class="panel panel-info"> <ul class="list-group"> <?php $stmt = $db->query("SELECT Month(postDate) as Month, Year(postDate) as Year FROM sa_posts GROUP BY Month(postDate), Year(postDate) ORDER BY postDate DESC"); while($row = $stmt->fetch()){ $monthName = date("F", mktime(0, 0, 0, $row['Month'], 10)); $slug = 'a-'.$row['Month'].'-'.$row['Year']; echo '<a href='.$slug.' class="list-group-item">'.$monthName.'</a>'; } ?> </ul> </div> </div> <!--end of tags--> </div> <!--end of right box--> |
viewpost.php
The inner page only holds all data from the individual article, you can see all the detailed information from the particular article with the date of post and category.
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 103 104 |
<?php require('includes/config.php'); $stmt = $db->prepare('SELECT * FROM sa_posts WHERE postSlug = :postSlug'); $stmt->execute(array(':postSlug' => $_GET['id'])); $row = $stmt->fetch(); //if post does not exists redirect user. if($row['postID'] == ''){ header('Location: ./'); exit; } ?> <!DOCTYPE html> <html> <head> <title>softAOX - <?php echo $row['postTitle'];?></title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name='keywords' content='<?php echo $row['postTitle'];?>'> <meta name='description' content='<?php echo $row['postCont']; ?>'> <meta name='copyright' content='softAOX'> <meta name='language' content='en'> <meta name='robots' content='index,follow'> <!--css--> <link href="assets/css/master.css" rel="stylesheet" type="text/css"> <!--jquery--> <link rel="icon" type="image/png" href="assets/images/favicon.ico" sizes="16x16"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="assets/js/general.js" type="text/javascript"></script> </head> <body class="bg"> <div class="top-line"> </div> <!--end of line--> <div class="top-bar"> <div class="logo"> <a href="./"><img src="assets/images/softaox_blog.svg"/></a> </div> <!--end of logo--> <?php include ('includes/navbar.php'); ?> <!--end navbar --> </div> <!--end of top bar--> <div class="all-container"> <div class="row nopadding full-section"> <div class="col-md-12 nopadding"> <div class="col-md-7 nopadding"> <div class="blog-listing"> <?php echo '<div>'; echo '<h1>'.$row['postTitle'].'</h1>'; echo '<div class="blog-listing-one-img inner-page">'; echo '<a href="'.$row['postSlug'].'"><img src="admin/uploads/'.$row['image'].'" width="100%"></a>'; echo '</div>'; echo'<div class="blog-listing-one-like-bookmark">'; echo '<ul>'; echo '<li><i class="fa fa-calendar" aria-hidden="true"></i><span> On:</span> '.date('jS M Y', strtotime($row['postDate'])).'</li>'; $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM sa_categories, sa_post_categories WHERE sa_categories.catID = sa_post_categories.catID AND sa_post_categories.postID = :postID'); $stmt2->execute(array(':postID' => $row['postID'])); $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC); $links = array(); foreach ($catRow as $cat) { $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>"; } echo '<li><i class="fa fa-folder-open"></i><span> Category: </span>'.implode(", ", $links).'</li>'; echo '</ul>'; echo '</div>'; echo '<p>'.$row['postCont'].'</p>'; echo '</div>'; ?> </div> <!--end of blog listing--> </div> <!--end of col-md-7--> <div class="col-md-5 nopadding padding-left"> <div id='sidebar'> <?php require('sidebar.php'); ?> </div> </div> <!--end of col-05--> </div> <!--end of col-md-12--> </div> <!--end of row--> </div> <!--end of all container--> <?php include ('includes/footer.php'); ?> <!--end of footer--> </body> </html> |
catpost-c.php
Based on a category where you can list the articles, using .htaccess you need to write the condition this make to redirect with the c- prefix category list.
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 103 104 105 106 107 108 109 |
<?php require('includes/config.php'); $stmt = $db->prepare('SELECT catID,catTitle FROM sa_categories WHERE catSlug = :catSlug'); $stmt->execute(array(':catSlug' => $_GET['id'])); $row = $stmt->fetch(); //if post does not exists redirect user. if($row['catID'] == ''){ header('Location: ./'); exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Blog - <?php echo $row['catTitle'];?> </title> <meta name='robots' content='index,follow'> <link rel="stylesheet" href="style/normalize.css"> <link rel="stylesheet" href="style/main.css"> </head> <body> <div id="wrapper"> <h1>Blog</h1> <p>Posts in <?php echo $row['catTitle'];?> </p> <hr /> <p><a href="./">Blog Index</a></p> <div id='main'> <?php try { $pages = new Paginator('1','p'); $stmt = $db->prepare('SELECT sa_posts.postID FROM sa_posts, sa_post_categories WHERE sa_posts.postID = sa_post_categories.postID AND sa_post_categories.catID = :catID'); $stmt->execute(array(':catID' => $row['catID'])); //pass number of records to $pages->set_total($stmt->rowCount()); $stmt = $db->prepare(' SELECT sa_posts.postID, sa_posts.postTitle, sa_posts.postSlug, sa_posts.postDesc, sa_posts.postDate FROM sa_posts, sa_post_categories WHERE sa_posts.postID = sa_post_categories.postID AND sa_post_categories.catID = :catID ORDER BY postID DESC '.$pages->get_limit()); $stmt->execute(array(':catID' => $row['catID'])); while($row = $stmt->fetch()){ echo '<div>'; echo '<h1><a href="'.$row['postSlug'].'">'.$row['postTitle'].'</a></h1>'; echo '<p>Posted on '.date('jS M Y H:i:s', strtotime($row['postDate'])).' in '; $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM sa_categories, sa_post_categories WHERE sa_categories.catID = sa_post_categories.catID AND sa_post_categories.postID = :postID'); $stmt2->execute(array(':postID' => $row['postID'])); $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC); $links = array(); foreach ($catRow as $cat) { $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>"; } echo implode(", ", $links); echo '</p>'; echo '<p>'.$row['postDesc'].'</p>'; echo '<p><a href="'.$row['postSlug'].'">Read More</a></p>'; echo '</div>'; } echo $pages->page_links('c-'.$_GET['id'].'&'); } catch(PDOException $e) { echo $e->getMessage(); } ?> </div> <div id='sidebar'> <?php require('sidebar.php'); ?> </div> <div id='clear'></div> </div> </body> </html> |
catpost.php
Once you selected an article from the category page next you redirected to the category inner post page, this will hold all the data’s for the particular article.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
<?php require('includes/config.php'); $stmt = $db->prepare('SELECT * FROM sa_categories WHERE catSlug = :catSlug'); $stmt->execute(array(':catSlug' => $_GET['id'])); $row = $stmt->fetch(); //if post does not exists redirect user. if($row['catID'] == ''){ header('Location: ./'); exit; } ?> <!DOCTYPE html> <html> <head> <title>softAOX - <?php echo $row['catTitle'];?> </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name='robots' content='index,follow'> <!--css--> <link href="assets/css/master.css" rel="stylesheet" type="text/css"> <!--jquery--> <link rel="icon" type="image/png" href="assets/images/favicon.ico" sizes="16x16"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="assets/js/general.js" type="text/javascript"></script> </head> <body class="bg"> <div class="top-line"> </div> <!--end of line--> <div class="top-bar"> <div class="logo"> <a href="index.php"><img src="assets/images/softaox_blog.svg" /></a> </div> <!--end of logo--> <?php include ('includes/navbar.php'); ?> <!--end navbar --> <a href="#" id="mob-nav"><i class="fa fa-bars"></i></a> </div> <!--end of top bar--> <div class="all-container"> <h1>Blog</h1> <h4>Catgories List: <?php echo $row['catTitle'];?></h4> <hr /> <p><a href="./">Back</a></p> <div class="row nopadding"> <div class="col-md-12 nopadding"> <div class="col-md-7 nopadding"> <div class="blog-listing"> <?php try { $pages = new Paginator('4','p'); $stmt = $db->prepare('SELECT sa_posts.postID FROM sa_posts, sa_post_categories WHERE sa_posts.postID = sa_post_categories.postID AND sa_post_categories.catID = :catID'); $stmt->execute(array(':catID' => $row['catID'])); //pass number of records to $pages->set_total($stmt->rowCount()); $stmt = $db->prepare(' SELECT sa_posts.postID, sa_posts.postTitle, sa_posts.image, sa_posts.postSlug, sa_posts.postDesc, sa_posts.postDate FROM sa_posts, sa_post_categories WHERE sa_posts.postID = sa_post_categories.postID AND sa_post_categories.catID = :catID ORDER BY postID DESC '.$pages->get_limit()); $stmt->execute(array(':catID' => $row['catID'])); while($row = $stmt->fetch()){ echo '<div class="blog-listing-one">'; echo '<h2><a href="'.$row['postSlug'].'">'.$row['postTitle'].'</a></h2>'; echo '<div class="blog-listing-one-img">'; echo '<a href="'.$row['postSlug'].'"><img src="admin/uploads/'.$row['image'].'" width="100%"></a>'; echo '</div>'; echo'<div class="blog-listing-one-like-bookmark">'; echo '<ul>'; echo '<li><i class="fa fa-calendar" aria-hidden="true"></i><span> On:</span> '.date('jS M Y', strtotime($row['postDate'])).'</li>'; $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM sa_categories, sa_post_categories WHERE sa_categories.catID = sa_post_categories.catID AND sa_post_categories.postID = :postID'); $stmt2->execute(array(':postID' => $row['postID'])); $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC); $links = array(); foreach ($catRow as $cat) { $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>"; } echo '<li><i class="fa fa-folder-open"></i><span> Category: </span>'.implode(", ", $links).'</li>'; echo '</ul>'; echo '</div>'; echo '<p>'.$row['postDesc'].'</p>'; echo '<a href="'.$row['postSlug'].'" class="btn-readmore">Continue Reading</a>'; echo '</div>'; } echo $pages->page_links('c-'.$_GET['id'].'&'); } catch(PDOException $e) { echo $e->getMessage(); } ?> </div> <!--end of blog listing--> </div> <!--end of col-md-7--> <div class="col-md-5 nopadding padding-left"> <div id='sidebar'> <?php require('sidebar.php'); ?> </div> </div> <!--end of col-05--> </div> <!--end of col-md-12--> </div> <!--end of row--> </div> <!--end of all container--> <?php include ('includes/footer.php'); ?> <!--end of footer--> </body> </html> |
archives.php
Archives help to show the articles from the month wise. If the user wants to see the article based on month wise means this will help a lot to the users.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
<?php require('includes/config.php'); ?> <!DOCTYPE html> <html> <head> <title>softAOX - Archives</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name='robots' content='index,follow'> <!--css--> <link href="assets/css/master.css" rel="stylesheet" type="text/css"> <!--jquery--> <link rel="icon" type="image/png" href="assets/images/favicon.ico" sizes="16x16"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="assets/js/general.js" type="text/javascript"></script> </head> <body class="bg"> <div class="top-line"> </div> <!--end of line--> <div class="top-bar"> <div class="logo"> <a href="index.php"><img src="assets/images/softaox_blog.svg" /></a> </div> <!--end of logo--> <?php include ('includes/navbar.php'); ?> <!--end navbar --> </div> <!--end of top bar--> <div class="all-container"> <h1>Blog</h1> <hr /> <p><a href="./">Back</a></p> <div class="row nopadding"> <div class="col-md-12 nopadding"> <div class="col-md-7 nopadding"> <div class="blog-listing"> <?php try { //collect month and year data $month = $_GET['month']; $year = $_GET['year']; //set from and to dates $from = date('Y-m-01 00:00:00', strtotime("$year-$month")); $to = date('Y-m-31 23:59:59', strtotime("$year-$month")); $pages = new Paginator('4','p'); $stmt = $db->prepare('SELECT postID FROM sa_posts WHERE postDate >= :from AND postDate <= :to'); $stmt->execute(array( ':from' => $from, ':to' => $to )); //pass number of records to $pages->set_total($stmt->rowCount()); $stmt = $db->prepare('SELECT * FROM sa_posts WHERE postDate >= :from AND postDate <= :to ORDER BY postID DESC '.$pages->get_limit()); $stmt->execute(array( ':from' => $from, ':to' => $to )); while($row = $stmt->fetch()){ echo '<div class="blog-listing-one">'; echo '<h2><a href="'.$row['postSlug'].'">'.$row['postTitle'].'</a></h2>'; echo '<div class="blog-listing-one-img">'; echo '<a href="'.$row['postSlug'].'"><img src="admin/uploads/'.$row['image'].'" width="100%"></a>'; echo '</div>'; echo'<div class="blog-listing-one-like-bookmark">'; echo '<ul>'; echo '<li><i class="fa fa-calendar" aria-hidden="true"></i><span> On:</span> '.date('jS M Y', strtotime($row['postDate'])).'</li>'; $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM sa_categories, sa_post_categories WHERE sa_categories.catID = sa_post_categories.catID AND sa_post_categories.postID = :postID'); $stmt2->execute(array(':postID' => $row['postID'])); $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC); $links = array(); foreach ($catRow as $cat) { $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>"; } echo '<li><i class="fa fa-folder-open"></i><span> Category: </span>'.implode(", ", $links).'</li>'; echo '</ul>'; echo '</div>'; echo '<p>'.$row['postDesc'].'</p>'; echo '<a href="'.$row['postSlug'].'" class="btn-readmore">Continue Reading</a>'; echo '</div>'; } echo $pages->page_links("a-$month-$year&"); } catch(PDOException $e) { echo $e->getMessage(); } ?> </div> <!--end of blog listing--> </div> <!--end of col-md-7--> <div class="col-md-5 nopadding padding-left"> <div id='sidebar'> <?php require('sidebar.php'); ?> </div> </div> <!--end of col-05--> </div> <!--end of col-md-12--> </div> <!--end of row--> </div> <!--end of all container--> <?php include ('includes/footer.php'); ?> <!--end of footer--> </body> </html> |
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]