-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass.post.php
executable file
·174 lines (134 loc) · 4.87 KB
/
class.post.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
<?php
class paginate
{
private $db;
function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
// $this->db = $conn;
}
public function dataview($query)
{
// error_reporting( ~E_NOTICE ); // avoid notice
// $farmer_name = new FARMER();
// $stmt = $farmer_name->runQuery("SELECT * FROM tbl_farmers WHERE email=:email_id");
// $stmt->execute(array(":email_id"=>$_SESSION['farmerSession']));
// $name = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt = $this->conn->prepare($query);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
// if (isset($_POST['btn-more'])) {
// $btn = trim($_POST['btn-more']);
// header("Location: index.php?more_view");
// }
?>
<div class="col-md-3 col-xs-6 col-sm-3 row-eq-height " id="mauni">
<div class="card panel panel-default" id="item-single">
<div class="img-solo panel-heading __item-image">
<?php if ( $row['photo']==''){
echo "";
}else {?>
<img src="post_images/<?php echo $row['photo']; ?>" class=" product-img item_image img-responsive" />
<?php }
?>
</div>
<div class="post-solo panel-body">
<!-- <p class="itemed"><?php //echo $row['cartegory']; ?></p> -->
<h5 class="itemed h4"><b><?php echo $row['title']; ?></b>
<span style="font-style: italic; "><?php
date_default_timezone_set('Africa/Nairobi');
$timed = $row['timer'];
$timestamp = strtotime($timed);
$strTime = array("sec", "min", "hr", "day", "mth", "yr");
$length = array("60","60","24","30","12","10");
$currentTime = time();
if($currentTime >= $timestamp) {
$diff = time()- $timestamp;
for($i = 0; $diff >= $length[$i] && $i < count($length)-1; $i++) {
$diff = $diff / $length[$i];
}
$diff = round($diff);
$timeded = $diff . " " . $strTime[$i] . "(s) ";
echo $timeded;
} ?></span> </h5>
<span class="phoned"><b>Sh. <?php echo $row['price']; ?></b></span>
<span class="phoned"> | <?php echo $row['email']; ?> | <?php echo $row['location']; ?></span>
</div>
<div class="panel-footer">
<div class="" role="group" aria-label="Basic example" style="width:100%">
<a href="tel:+254-<?php echo $row['phone']; ?>" type="button" class="btn small btn-secondary btn-sm __item-cta" style="font-size: 10px;width:100%"><?php echo $row['phone']; ?></a>
<a href="post_view.php?var=<?php echo $row['ID']; ?>" class="btn small btn-secondary btn-sm __item-cta" style="font-size: 10px;width:100%">View Product</a>
</div>
</div>
</div>
</div>
<?php
}
}
else
{
?>
<div class="__nothing">
<i class="fa fa-meh-o"></i>
<h1 class="__nothing-text">Nothing here</h1>
</div>
<?php
}
}
public function paging($query,$records_per_page)
{
$starting_position=0;
if(isset($_GET["page_no"]))
{
$starting_position=($_GET["page_no"]-1)*$records_per_page;
}
$query2=$query." limit $starting_position,$records_per_page";
return $query2;
}
public function paginglink($query,$records_per_page)
{
$self = $_SERVER['PHP_SELF'];
$stmt = $this->conn->prepare($query);
$stmt->execute();
$total_no_of_records = $stmt->rowCount();
if($total_no_of_records > 0)
{
?><tr><td colspan="3"><?php
$total_no_of_pages=ceil($total_no_of_records/$records_per_page);
$current_page=1;
if(isset($_GET["page_no"]))
{
$current_page=$_GET["page_no"];
}
if($current_page!=1)
{
$previous =$current_page-1;
echo "<li><a href='".$self."?page_no=1'>First</a> </li>";
echo "<li><a href='".$self."?page_no=".$previous."'>Previous</a> </li>";
}
for($i=1;$i<=$total_no_of_pages;$i++)
{
if($i==$current_page)
{
echo "<li class='active'><a href='".$self."?page_no=".$i."'>".$i."</a></li>";
}
else
{
echo "<li><a href='".$self."?page_no=".$i."'>".$i."</a> </li>";
}
}
if($current_page!=$total_no_of_pages)
{
$next=$current_page+1;
echo "<li><a href='".$self."?page_no=".$next."'>Next</a> </li>";
echo "<li><a href='".$self."?page_no=".$total_no_of_pages."'>Last</a> </li>";
}
?></td></tr><?php
}
}
}