final commit
91
blog.php
|
@ -30,52 +30,55 @@ $posts=mysqli_query($connection,$query);
|
|||
|
||||
|
||||
<!-- ===================END OF SEARCH================-->
|
||||
<section class="posts <?= $featured ? "" : "section__extra-margin" ?>">
|
||||
<!-- #region POSTS -->
|
||||
|
||||
<div class="container posts__container">
|
||||
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail">
|
||||
<img src="./images/<?=$post['thumbnail']?>" >
|
||||
</div>
|
||||
<div class="post__info">
|
||||
<?php
|
||||
//fetch category
|
||||
$category_id=$post['category_id'];
|
||||
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||
$category_result=mysqli_query($connection,$category_query);
|
||||
$category=mysqli_fetch_assoc($category_result);
|
||||
|
||||
$author_id=$post['author_id'];
|
||||
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result=mysqli_query($connection,$author_query);
|
||||
$author=mysqli_fetch_assoc($author_result);
|
||||
|
||||
?>
|
||||
<a href="category-posts.php?id=<?=$post['category_id']?>" class="category__button"><?=$category['title']?></a>
|
||||
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||
<?=$post['title']?>
|
||||
</a></h3>
|
||||
<p class="post__body">
|
||||
<?= substr($post['body'],0,150) ?>...
|
||||
</p>
|
||||
<div class="post__author">
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>">
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||
<small>
|
||||
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
<?php endwhile ?>
|
||||
<section class="posts <?= $featured ? '' : 'section__extra-margin' ?>">
|
||||
<div class="container posts__container">
|
||||
<?php while ($post = mysqli_fetch_assoc($posts)) : ?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail" style="width: 300px; height: 200px;">
|
||||
<img src="./images/<?= $post['thumbnail'] ?>" >
|
||||
</div>
|
||||
</section>
|
||||
<div class="post__info">
|
||||
<?php // fetch category from categories using category_id
|
||||
$category_id = $post['category_id'];
|
||||
$category_query = "SELECT * FROM categories WHERE id=$category_id";
|
||||
$category_result = mysqli_query($connection, $category_query);
|
||||
$category = mysqli_fetch_assoc($category_result);
|
||||
?>
|
||||
<a href="<?= ROOT_URL ?>category-posts.php?id=<?= $post['category_id'] ?>" class="category__button"><?= $category['title'] ?></a>
|
||||
<h2 class="post__title"><a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>"><?= $post['title'] ?></a></h2>
|
||||
<a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>">
|
||||
|
||||
<p class="post__body" style="min-height: 100px;">
|
||||
<?= substr($post['body'], 0, 120) ?>...
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<div class="post__author">
|
||||
<?php
|
||||
// Fetch author from users table using author id
|
||||
$author_id = $post['author_id'];
|
||||
$author_query = "SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result = mysqli_query($connection, $author_query);
|
||||
$author = mysqli_fetch_assoc($author_result);
|
||||
$author_firstname = $author['firstname'];
|
||||
$author_lastname = $author['lastname'];
|
||||
?>
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>" alt="" />
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author_firstname} {$author_lastname}" ?></h5>
|
||||
<small><?= date("M d, Y - H:i", strtotime($post['date_time'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</h3>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,44 +27,50 @@ if(isset($_GET['id'])){
|
|||
|
||||
|
||||
<?php if ((mysqli_num_rows($posts)) > 0) : ?>
|
||||
<section class="posts">
|
||||
<section class="posts <?= $featured ? '' : 'section__extra-margin' ?>">
|
||||
<div class="container posts__container">
|
||||
<?php while ($post = mysqli_fetch_assoc($posts)) : ?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail" style="width: 300px; height: 200px;">
|
||||
<img src="./images/<?= $post['thumbnail'] ?>" >
|
||||
</div>
|
||||
<div class="post__info">
|
||||
<?php // fetch category from categories using category_id
|
||||
$category_id = $post['category_id'];
|
||||
$category_query = "SELECT * FROM categories WHERE id=$category_id";
|
||||
$category_result = mysqli_query($connection, $category_query);
|
||||
$category = mysqli_fetch_assoc($category_result);
|
||||
?>
|
||||
<a href="<?= ROOT_URL ?>category-posts.php?id=<?= $post['category_id'] ?>" class="category__button"><?= $category['title'] ?></a>
|
||||
<h2 class="post__title"><a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>"><?= $post['title'] ?></a></h2>
|
||||
<a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>">
|
||||
|
||||
<div class="container posts__container">
|
||||
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail">
|
||||
<img src="./images/<?=$post['thumbnail']?>" >
|
||||
</div>
|
||||
<div class="post__info">
|
||||
<?php
|
||||
<p class="post__body" style="min-height: 100px;">
|
||||
<?= substr($post['body'], 0, 120) ?>...
|
||||
</p>
|
||||
</a>
|
||||
|
||||
|
||||
$author_id=$post['author_id'];
|
||||
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result=mysqli_query($connection,$author_query);
|
||||
$author=mysqli_fetch_assoc($author_result);
|
||||
|
||||
?>
|
||||
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||
<?=$post['title']?>
|
||||
</a></h3>
|
||||
<p class="post__body">
|
||||
<?= substr($post['body'],0,150) ?>...
|
||||
</p>
|
||||
<div class="post__author">
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>">
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||
<small>
|
||||
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
<div class="post__author">
|
||||
<?php
|
||||
// Fetch author from users table using author id
|
||||
$author_id = $post['author_id'];
|
||||
$author_query = "SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result = mysqli_query($connection, $author_query);
|
||||
$author = mysqli_fetch_assoc($author_result);
|
||||
$author_firstname = $author['firstname'];
|
||||
$author_lastname = $author['lastname'];
|
||||
?>
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>" alt="" />
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author_firstname} {$author_lastname}" ?></h5>
|
||||
<small><?= date("M d, Y - H:i", strtotime($post['date_time'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</h3>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile ?>
|
||||
|
||||
|
||||
|
|
1437
css/style.css
BIN
images/1678235515avatar9.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
images/1678235660blog17.jpg
Normal file
After Width: | Height: | Size: 109 KiB |
BIN
images/1678235943blog7.jpg
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
images/1678236024avatar4.jpg
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
images/1678236380blog18.jpg
Normal file
After Width: | Height: | Size: 224 KiB |
BIN
images/1678237029avatar8.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
images/1678237190blog101.jpg
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
images/1678237466blog2.jpg
Normal file
After Width: | Height: | Size: 63 KiB |
95
index.php
|
@ -9,7 +9,7 @@ $featured=mysqli_fetch_assoc($featured_result);
|
|||
//fetch 9post
|
||||
|
||||
|
||||
$query="SELECT * FROM posts ORDER BY date_time DESC LIMIT 9";
|
||||
$query="SELECT * FROM posts WHERE is_featured=0 ORDER BY date_time DESC LIMIT 9";
|
||||
$posts=mysqli_query($connection,$query);
|
||||
|
||||
|
||||
|
@ -57,52 +57,57 @@ $posts=mysqli_query($connection,$query);
|
|||
<?php endif ?>
|
||||
<!-- ===================END OF FEATURED================-->
|
||||
|
||||
<section class="posts <?= $featured ? "" : "section__extra-margin" ?>">
|
||||
<!-- #region POSTS -->
|
||||
|
||||
<div class="container posts__container">
|
||||
<?php while ($post=mysqli_fetch_assoc($posts)) :?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail">
|
||||
<img src="./images/<?=$post['thumbnail']?>" >
|
||||
</div>
|
||||
<div class="post__info">
|
||||
<?php
|
||||
//fetch category
|
||||
$category_id=$post['category_id'];
|
||||
$category_query="SELECT * FROM categories WHERE id=$category_id";
|
||||
$category_result=mysqli_query($connection,$category_query);
|
||||
$category=mysqli_fetch_assoc($category_result);
|
||||
|
||||
$author_id=$post['author_id'];
|
||||
$author_query="SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result=mysqli_query($connection,$author_query);
|
||||
$author=mysqli_fetch_assoc($author_result);
|
||||
|
||||
?>
|
||||
<a href="category-posts.php?id=<?=$post['category_id']?>" class="category__button"><?=$category['title']?></a>
|
||||
<h3 class="post__title"><a href="post.php?id=<?=$post["id"]?>" >
|
||||
<?=$post['title']?>
|
||||
</a></h3>
|
||||
<p class="post__body">
|
||||
<?= substr($post['body'],0,150) ?>...
|
||||
</p>
|
||||
<div class="post__author">
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>">
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author['firstname']} {$author['lastname']}" ?></h5>
|
||||
<small>
|
||||
<?=date("M d, Y -H:i" , strtotime($post['date_time']))?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
<?php endwhile ?>
|
||||
<section class="posts <?= $featured ? '' : 'section__extra-margin' ?>">
|
||||
<div class="container posts__container">
|
||||
<?php while ($post = mysqli_fetch_assoc($posts)) : ?>
|
||||
<article class="post">
|
||||
<div class="post__thumbnail" style="width: 300px; height: 200px;">
|
||||
<img src="./images/<?= $post['thumbnail'] ?>" >
|
||||
</div>
|
||||
</section>
|
||||
<div class="post__info">
|
||||
<?php // fetch category from categories using category_id
|
||||
$category_id = $post['category_id'];
|
||||
$category_query = "SELECT * FROM categories WHERE id=$category_id";
|
||||
$category_result = mysqli_query($connection, $category_query);
|
||||
$category = mysqli_fetch_assoc($category_result);
|
||||
?>
|
||||
<a href="<?= ROOT_URL ?>category-posts.php?id=<?= $post['category_id'] ?>" class="category__button"><?= $category['title'] ?></a>
|
||||
<h2 class="post__title"><a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>"><?= $post['title'] ?></a></h2>
|
||||
<a href="<?= ROOT_URL ?>post.php?id=<?= $post['id'] ?>">
|
||||
|
||||
<p class="post__body" style="min-height: 100px;">
|
||||
<?= substr($post['body'], 0, 150) ?>...
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<div class="post__author">
|
||||
<?php
|
||||
// Fetch author from users table using author id
|
||||
$author_id = $post['author_id'];
|
||||
$author_query = "SELECT * FROM users WHERE id=$author_id";
|
||||
$author_result = mysqli_query($connection, $author_query);
|
||||
$author = mysqli_fetch_assoc($author_result);
|
||||
$author_firstname = $author['firstname'];
|
||||
$author_lastname = $author['lastname'];
|
||||
?>
|
||||
<div class="post__author-avatar">
|
||||
<img src="./images/<?= $author['avatar'] ?>" alt="" />
|
||||
</div>
|
||||
<div class="post__author-info">
|
||||
<h5>By: <?= "{$author_firstname} {$author_lastname}" ?></h5>
|
||||
<small><?= date("M d, Y - H:i", strtotime($post['date_time'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</h3>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
</section>
|
||||
<!-- #endregion POSTS -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
|