-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
143 lines (127 loc) · 4.85 KB
/
index.php
File metadata and controls
143 lines (127 loc) · 4.85 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
134
135
136
137
138
139
140
141
142
143
<?php require_once 'inc/connection.php' ?>
<?php require_once 'inc/function.php' ?>
<?php require_once 'inc/header.php' ?>
<!-- Page Content -->
<!-- Banner Starts Here -->
<div class="banner header-text">
<div class="owl-banner owl-carousel">
<div class="banner-item-01">
<div class="text-content">
<!-- <h4>Best Offer</h4> -->
<!-- <h2>New Arrivals On Sale</h2> -->
</div>
</div>
<div class="banner-item-02">
<div class="text-content">
<!-- <h4>Flash Deals</h4> -->
<!-- <h2>Get your best products</h2> -->
</div>
</div>
<div class="banner-item-03">
<div class="text-content">
<!-- <h4>Last Minute</h4> -->
<!-- <h2>Grab last minute deals</h2> -->
</div>
</div>
</div>
</div>
<!-- Banner Ends Here -->
<?php
/*
if(isset($_SESSION['errors'])){
printErrorArray($_SESSION['errors']);
unset($_SESSION['errors']);
}
*/
?>
<?php
$page=1;
$limit=3;//define from clint
$numberPage=1;
if(isset($_GET['page'])){
$page=$_GET['page'];
}
//to define number page
$query="select count(`id`) as total from posts";
$runQuery=mysqli_query($conn,$query);
if(mysqli_num_rows($runQuery)==1){
$numberPage=ceil(mysqli_fetch_assoc($runQuery)['total']/$limit);
}
// validPage($page,$numberPage);
$offset=($page-1)*$limit;
?>
<?php
$query="select id,image, created_at,title,substring(body,1,53) as body from posts order by `id` limit $limit offset $offset ";
$runQuery=mysqli_query($conn,$query);
if($runQuery){
$posts=mysqli_fetch_all($runQuery,MYSQLI_ASSOC);
}
?>
<div class="latest-products">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-heading ">
<h2 class=<?php if($_SESSION['lang']=='ar') echo"text-end"?>><?= $mes['Latest Posts']?></h2>
<?php /*
if(isset($_SESSION['success'])){
printSuccessMessage($_SESSION['success']);
unset($_SESSION['success']);
}
*/
?>
<!-- <a href="products.html">view all products <i class="fa fa-angle-right"></i></a> -->
</div>
</div>
<?php
if(isset($_SESSION['success'])){
printSuccessMessage($_SESSION['success']);
unset($_SESSION['success']);
}
?>
<?php
foreach($posts as $post):
?>
<div class="col-md-4">
<div class="product-item">
<!-- check if there is an picture or not -->
<?php if(!empty($post['image'])):?>
<a href="#" width=><img src="upload/<?=$post['image'] ?>"height="200" width="300" alt=""></a><?php endif;?>
<div class="down-content">
<a href="#"><h4><?=$post['title']?></h4></a>
<h5><?=$post['created_at']?></h5>
<p><?=$post['body']."..."?></p>
<!-- <ul class="stars">
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
</ul>
<span>Reviews (24)</span> -->
<div class="d-flex justify-content-end">
<a href="viewPost.php?id=<?=$post['id'];?>" class="btn btn-info "> <?= $mes['view']?></a>
</div>
</div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<!-- -->
<div class=' d-flex justify-content-center'>
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item <?php if($page==1) echo "disabled";?>"><a class="page-link" href="index.php?page=<?=$page-1;?>"><?=$mes['Previous']?></a></li>
<li class="page-item"><a class="page-link" href="index.php?page=<?=$page;?>"><?="$page"?></a></li>
<?php if($page+1<=$numberPage):?>
<li class="page-item"><a class="page-link" href="index.php?page=<?=$page+1;?>"><?="$page"+1?></a></li><?php endif;?>
<?php if($page+2<=$numberPage):?>
<li class="page-item"><a class="page-link" href="index.php?page=<?=$page+2;?>"><?="$page"+2?></a></li><?php endif;?>
<li class="page-item <?php if($page==$numberPage) echo "disabled";?>" ><a class="page-link" href="index.php?page=<?=$page+1?>"><?=$mes['Next']?></a></li>
</ul>
</nav>
</div>
<!-- -->
</div>
<?php require_once 'inc/footer.php' ?>