-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathread_comments.php
executable file
·65 lines (54 loc) · 2.35 KB
/
read_comments.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
<?php
session_start();
require_once 'class.farmer.php';
require_once 'consultants/class.consultant.php';
$farmer_home = new FARMER();
$admin_home = new CONSULTANT();
$stmt = $farmer_home->runQuery("SELECT * FROM comment_posts WHERE postID=:email_id ORDER BY ID DESC LIMIT 10");
$stmt->execute(array(":email_id"=>$_SESSION['$var']));
if($stmt->rowCount()>0){
while ($comm = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="col-md-3 col-sm-3 col-xs-2">
<?php
if ($comm['userpic']=="") {
$pic3 = "<img class='img-circle ' src='img/user.png' style='' padding:0px; height=50px width=50px />";
}
?>
<?php
if(isset($pic3)){
echo $pic3;
} else { ?>
<img class="img-circle " src="farmer_images/<?php echo $comm['userpic']; ?>" style=" padding:0px;" height=50px />
<?php
}?>
</div>
<div class="col-md-9 col-sm-9 col-xs-10">
<p class="text"><?php echo $comm['comment']; ?></p>
<span class="phoned"><?php echo $comm['email']; ?>
<span class="itemed h5 " style="font-style: italic;"><?php
date_default_timezone_set('Africa/Nairobi');
$timed = $comm['timer'];
$timestamp = strtotime($timed);
$strTime = array("second", "minute", "hour", "day", "month", "year");
$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);
echo $diff . " " . $strTime[$i] . "(s) ago ";
} ?></span></span>
</div>
<?php }
} else
{
?>
<tr>
<td>No Comments here...</td>
</tr>
<?php
}
?>