-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.php
153 lines (150 loc) · 5.28 KB
/
blog.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
<?php
include "style/publicstyle.php";
include "database.php";
include "session.php";
?>
<html>
<head>
<title>Blog</title>
</head>
<body>
<div style="height:10px; background-color:#27aae1;"></div>
<nav class="navbar navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapse"><!-- java script not working. data-toggle and data-target are function of javascript -->
<span class="sr-only">Toggle-Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="blog.php"><img style="margin-top:-15px"src="images/spiddy.jpg" width=115;height=20;></a>
</div>
<div class="collapse navbar-collapse" id="collapse">
<ul class="nav navbar-nav">
<li><a href="#">Home</a></li>
<li class="active"><a href="blog.php">Blog</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Features</a></li>
</ul>
<form action="blog.php" class="navbar-form navbar-right">
<div class="form-group">
<input class="form-control"type="text" name="search" placeholder="Search" required>
</div>
<button class="btn btn-default" name="searchbtn">Go</button>
</form>
</div>
</div>
</nav>
<div class="line"style="height:10px; background-color:#27aae1;"></div>
<div class="container">
<div class="blog-header">
<h1>CMS Blog</h1>
<p class="lead">This blog is made by Spiddy Creations</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-8">
<?php
$query="select count(*) from admin_panel";
$execute=mysql_query($query);
$row=mysql_fetch_array($execute);
$total_post=array_shift($row);
$total_pages=ceil(($total_post/3));
$pageNo=1;
if(isset($_GET["searchbtn"]))
{
$search=$_GET["search"];
$query="select * from admin_panel where datetime like '%$search%' OR post like '%$search%' OR category like '%$search%' OR title like '%$search%' order by datetime desc";
}
else
{
if(isset($_GET["pg"]))
{
$pageNo=$_GET["pg"];
}
if($pageNo<1)$pageNo=1;
if($pageNo>$total_pages)$pageNo=$total_pages;
$query="select * from admin_panel order by datetime desc";
}
$execute=mysql_query($query);
$start=($pageNo*3)-3;
$end=($pageNo*3);
$sno=0;
while($row=mysql_fetch_array($execute))
{
$sno++;
if($sno>$start && $sno<=$end)
{
$title=$row["title"];
$category=$row["category"];
$post=$row["post"];
$image=$row["image"];
$author=$row["author"];
$datetime=$row["datetime"];
$id=$row["id"];?>
<div class="blogpost thumbnail"><!-- blogpost class is cutom -->
<img class="img-responsive img-rounded" src="image_upload/<?php echo $image;?>">
<div class="caption">
<h1 id="heading"> <?php echo $title;?> </h1>
<p class="description">Category : <?php echo $category;?><br>Published on : <?php echo $datetime;?><br>By : <?php echo $author;?></p>
<p class="post">
<?php if(strlen($post)>150) $post=substr($post,0,150)."...";?>
<?php echo $post ?>
</p>
</div>
<a href="fullpost.php?id=<?php echo $id ?>"><span class="btn btn-info">Read More ››<span></a>
</div><?php
}
}
if(!isset($_GET["searchbtn"]))
{?>
<nav>
<ul class="pagination pull-left pagination-lg"><?php
if($pageNo>1)
{?>
<li><a href="blog.php?pg=<?php echo $pageNo-1; ?>">«</a></li><?php
}
for($i=1;$i<=$total_pages;$i++)
{
if($i==$pageNo)
{?>
<li class="active"><a href="blog.php?pg=<?php echo $i; ?>"><?php echo $i;?></a></li><?php
}
else
{?>
<li><a href="blog.php?pg=<?php echo $i; ?>"><?php echo $i;?></a></li><?php
}
}
if($pageNo<$total_pages)
{?>
<li><a href="blog.php?pg=<?php echo $pageNo+1; ?>">»</a></li><?php
}?>
</ul>
</nav><?php
}
?>
</div>
<div class="col-sm-1">
</div>
<div class="col-sm-3">
<h2 class="text-center">About Us</h2><br>
<img class="img-responsive img-circle"src="images/frog.jpg"><br>
</div>
</div>
</div>
<div id="footer">
<hr><p>Theme By | Harshit Gupta | ©2016-2020 --- All right reserved.</p>
<a style="color:white;text-decoration:none;cursor:pointer;font-weight:bold;"href="">
<p>
This site is only use for study purpose spiddy creations have all right reserved.No one is allowed to distribute
copies other than <br> ™ spiddycreations.com ™ Udemy ; ™ Skillshare; ™ StackSkills
</p><hr> </a>
</div>
<div style="height:10px; background:#27aae1">
</div>
</body>
</html>