-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
115 lines (96 loc) · 4.52 KB
/
index.php
File metadata and controls
115 lines (96 loc) · 4.52 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
103
104
105
106
107
108
109
110
111
112
113
114
115
<!-- Grid item -->
<?php
require('inc/dbconfig.php'); ?>
<section class="py-5 header text-center">
<div class="container py-4">
<header>
<h1 class="display-4">Blog Website</h1>
<p class="font-italic text-muted mb-1">Create and upload blogs easily through our Website</p>
</header>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<?php
$query = "SELECT id, postTitle, description, post_date, author, catinfo,imgUrl FROM blog_posts ORDER BY id DESC";
$result = mysqli_query($con,$query);
if(!$result || mysqli_num_rows($result)==0)
{
echo 'noting';
}
else
{
while($row= mysqli_fetch_assoc($result))
{
$text=$row['description'];
if(strlen($text)>100)
{
$str2='...';
$text=substr($text,0,97);
$text=$text.$str2;
}
echo '<div class="col-lg-4 col-md-6 grid-item mb-4">';
echo '<a href="viewpost.php?id='.$row['id'].'&title='.$row['postTitle'].'">';
echo'<img class="img-fluid w-100 mb-3 img-thumbnail shadow-sm rounded-0" src='.$row['imgUrl'].' alt="">';
echo '</a>';
echo '<h2 class="h4">'.$row['postTitle'].'</h2>';
echo '<p class="small text-muted font-italic">'.$text.'</p>';
echo '</div>';
}
}
?>
</div>
</div>
</div>
<h1>Recent Posts</h1>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<?php
$query = "SELECT id, postTitle, description, post_date, author, catinfo,imgUrl FROM blog_posts ORDER BY post_date DESC";
$result = mysqli_query($con,$query);
if(!$result || mysqli_num_rows($result)==0)
{
echo 'noting';
}
else
{
while($row= mysqli_fetch_assoc($result))
{
$text=$row['description'];
if(strlen($text)>100)
{
$str2='...';
$text=substr($text,0,97);
$text=$text.$str2;
}
echo '<div class="col-lg-4 col-md-6 grid-item mb-4">';
echo '<a href="viewpost.php?id='.$row['id'].'&title='.$row['postTitle'].'">';
echo'<img class="img-fluid w-100 mb-3 img-thumbnail shadow-sm rounded-0" src='.$row['imgUrl'].' alt="">';
echo '</a>';
echo '<h2 class="h4">'.$row['postTitle'].'</h2>';
echo '<p class="small text-muted font-italic">'.$text.'</p>';
echo '</div>';
}
}
?>
</div>
</div>
</div>
<footer class="p-4 bg-light d-flex align-items-center justify-content-center">
<small class="mb-0 text-uppercase font-weight-bold mr-3">Resources: </small>
<ul class="list-inline mb-0 d-inline-block">
<li class="list-inline-item">
<a class="text-muted font-italic" target="_blank" ><u>Priyanshu </u></a>
</li>
<li class="list-inline-item">
<a class="text-muted font-italic" target="_blank" ><u>Prasham</u></a>
</li>
<li class="list-inline-item">
<a class="text-muted font-italic" target="_blank" ><u>Ridda</u></a>
</li>
</ul>
</footer>
</body>
</html>