-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
134 lines (108 loc) · 4.8 KB
/
Copy pathindex.php
File metadata and controls
134 lines (108 loc) · 4.8 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!-- Connection -->
<?php session_start(); ?>
<?php
include "./includes/db.php";
?>
<!-- Header -->
<?php
include "./includes/header.php";
?>
<!-- Navigation -->
<?php
include "./includes/navigation.php";
?>
<main>
<div class="container">
<div class="row">
<!-- blog-contents -->
<section class="col-md-8">
<!-- Logic for Pagination -->
<?php
$perPage = 2;
$post_query_count = "SELECT * FROM posts";
$find_count = mysqli_query($connection,$post_query_count);
$count = mysqli_num_rows($find_count);
$count = ceil($count/ $perPage);
if(isset($_GET['page'])){
$page = $_GET['page'];
}else{
$page = "";
}
if($page == "" || $page == 1 || $page == 0){
$page_1 = 0;
}else{
$page_1 = ($page * $perPage) - $perPage;
}
?>
<?php
include "includes/post.php";
?>
<!-- pagination -->
<div class="page-turn">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<nav>
<ul class="pagination pagination-sm">
<?php
if(isset($_GET['page'])){
if($_GET['page']==0){
?>
<li class="disabled">
<a href="" aria-label="Previous">
<span aria-hidden="true">Prev</span>
</a>
</li>
<?php
}
else{ ?>
<li class="">
<a href="index.php?page=<?php echo $_GET['page']-1 ?>" aria-label="Previous">
<span aria-hidden="true">Prev</span>
</a>
</li>
<?php } } ?>
<?php
for ($i=1; $i<=$count;$i++){
if($i == $page){
echo "<li><a style='background:black;color:orange;' href='index.php?page={$i}'>{$i}</a></li>";
}
else{
echo "<li><a href='index.php?page={$i}'>{$i}</a></li>";
}
}
?>
</ul>
</nav>
</div>
</div>
</div> <!-- /.page-turn -->
</section>
<section>
<!-- sidebar -->
<aside class="col-md-4 col-sm-8 col-xs-8">
<div class="sidebar">
<?php
if(!isset($_SESSION['loginCMS'])){
?>
<!-- Login Form -->
<div style="margin-left:40px;" class="search-widget">
<h3>Login</h3>
<form id="my_form" action="./includes/login.php" method="POST">
<div class="form-group">
<input name="log_username" class="form-control" type="text" placeholder="Enter Your username">
</div>
<div class="form-group">
<input name="log_password" class="form-control" type="password" placeholder="Enter Your password">
</div>
<button name="loginSubmit" type="submit" style="background:black;color:white;" class="btn btn-dark btn-block">Login</button>
</form>
</div>
<?php } ?>
<!-- Search and Category -->
<?php include "includes/sidebar.php"; ?>
</div>
</aside>
</section>
</div>
</div> <!-- end of /.container -->
</main>