-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogs-list.php
181 lines (169 loc) · 6.83 KB
/
blogs-list.php
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mini Blog</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<?php include('google-analytics.php'); ?>
<link
href="https://fonts.googleapis.com/css?family=Muli:300,400,700|Playfair+Display:400,700,900"
rel="stylesheet"
/>
<link rel="stylesheet" href="fonts/icomoon/style.css" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/magnific-popup.css" />
<link rel="stylesheet" href="css/jquery-ui.css" />
<link rel="stylesheet" href="css/owl.carousel.min.css" />
<link rel="stylesheet" href="css/owl.theme.default.min.css" />
<link rel="stylesheet" href="css/bootstrap-datepicker.css" />
<link rel="stylesheet" href="css/bootstrap-tagsinput.css" />
<link rel="stylesheet" href="fonts/flaticon/font/flaticon.css" />
<link rel="stylesheet" href="css/aos.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="site-wrap">
<div class="site-mobile-menu">
<div class="site-mobile-menu-header">
<div class="site-mobile-menu-close mt-3">
<span class="icon-close2 js-menu-toggle"></span>
</div>
</div>
<div class="site-mobile-menu-body"></div>
</div>
<header class="site-navbar" role="banner">
<div class="container-fluid">
<div class="row align-items-center">
<div class="col-12 search-form-wrap js-search-form">
<form method="get" action="#">
<input
type="text"
id="s"
class="form-control"
placeholder="Search..."
/>
<button class="search-btn" type="submit">
<span class="icon-search"></span>
</button>
</form>
</div>
<div class="col-4 site-logo">
<a href="index.php" class="text-black h2 mb-0">Blog-It</a>
</div>
<div class="col-8 text-right">
<nav class="site-navigation" role="navigation">
<ul
class="site-menu js-clone-nav mr-auto d-none d-lg-block mb-0"
>
<li><a href="index.php">Home</a></li>
<li><a href="category.php?category=politics">Politics</a></li>
<li><a href="category.php?category=nature">Nature</a></li>
<li><a href="category.php?category=tech">Tech</a></li>
<li><a href="category.php?category=travel">Travel</a></li>
<li><a href="category.php?category=sports">Sports</a></li>
<?php
if(isset($_SESSION['user_id'])){
echo "<li><a href='logout.php'>Log Out</a></li>";
echo "<li class='disabled'><a href='user_profile.php'>"."Hello, ".$_SESSION['ufname']."</a></li>";
}else{
echo "<li><a href='login.php'>Log In</a></li>";
}
?>
<li><a href="compose.php">Create Blog</a></li>
</ul>
</nav>
<a
href="#"
class="site-menu-toggle js-menu-toggle text-black d-inline-block d-lg-none"
><span class="icon-menu h3"></span
></a>
</div>
</div>
</div>
</header>
<div class="site-section bg-light">
<div class="container">
<div class="container">
<div class="row same-height justify-content-center">
<div class="col-md-12 col-lg-10">
<div class="post-entry text-center">
<h1 class="">List Of Blogs</h1>
</div>
</div>
</div>
</div>
<table border="1" align="center" class="table">
<thead class="thead-dark">
<th scope="col">#</th>
<th scope="col">Author</th>
<th scope="col">Title</th>
<th scope="col">Subtitle</th>
<th scope="col">Intro</th>
<th scope="col">Main</th>
<th scope="col">Conclusion</th>
<th scope="col">Additional Readings</th>
<th scope="col">Tags</th>
<th scope="col">Categories</th>
<th scope="col">Edit Link</th>
<th scope="col">View Link</th>
</thead>
<tbody>
<?php
$author = $_SESSION["user_id"];
include_once('creds.php');
if(!$conn){
die("<br>Error in creating a connection: " . mysqli_connect_error());
}else{
$query = mysqli_query($conn, "SELECT * FROM blogs WHERE author='$author'")
or die (mysqli_error($conn));
while ($row = mysqli_fetch_array($query)) {
$main = substr($row['main'],0,50);
$intro = substr($row['intro'],0,50);
$conclusion = substr($row['conclusion'],0,50);
$id = $row['id'];
// $categories = implode(',', $row['categories']);
echo
"<tr>
<th scope='row'>{$id}</th>
<td>{$row['author']}</td>
<td>{$row['title']}</td>
<td>{$row['subtitle']}</td>
<td>{$intro}</td>
<td>{$main}...</td>
<td>{$conclusion}</td>
<td>{$row['additionalReadings']}</td>
<td>{$row['tags']}</td>
<td>{$row['categories']}</td>
<td><a href=\"compose.php?blog_id=$id\" class=\"btn btn-success btn-lg active\" role=\"button\" aria-pressed=\"true\">Update Blog</a></td>
<td><a href=\"blog.php?blog_id=$id\" class=\"btn btn-primary btn-lg active\" role=\"button\" aria-pressed=\"true\">View Blog</a></td>
</tr>\n";
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include_once('footer.php'); ?>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/jquery-migrate-3.0.1.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.stellar.min.js"></script>
<script src="js/jquery.countdown.min.js"></script>
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/bootstrap-datepicker.min.js"></script>
<script src="js/bootstrap-tagsinput.js"></script>
<script src="js/aos.js"></script>
<script src="js/main.js"></script>
</body>
</html>