-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomment.php
125 lines (101 loc) · 2.67 KB
/
comment.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
<!DOCTYPE html>
<html>
<head>
<title>Lobelia</title>
<style type="text/css">
.comment_box{
border:none;
resize: none;
width: 98%;
height: 34px;
outline:none;
padding:5px 15px;
}
.comment_area{
height: 300px;
overflow-y: scroll;
}
.comment_area::-webkit-scrollbar {
display: none;
}
</style>
<?php include('cdn.php'); ?>
</head>
<body style="background:#E9EBEE;">
<?php include ('nav.php'); ?>
<div class="container-fluid" style="margin-top: 80px;">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-5">
<?php
if (isset($_GET['id']))
{
$id=$_GET['id'];
$_SESSION['pid']=$id;
$post_sql=mysqli_query($conn,"SELECT post.*,user.name,user.photo FROM post INNER JOIN user ON post.user_id=user.id WHERE post.id='$id'");
$post=mysqli_fetch_assoc($post_sql);
}
?>
<div class="card">
<div class="card-header bg-white">
<a href="" class="card-link text-dark">
<img src="img/<?php echo $post['photo']?>" height="30px" width="30px" class="rounded-circle mr-1">
<b><?php echo $post['name']?></b></a>
</div>
<div class="card-body">
<h6><?php echo $post['title']?></h6>
<p class="text-justify"><?php echo $post['description']?></p>
<?php
if ($post['post_photo'])
{ ?>
<img src="img/<?php echo $post['post_photo']?>" width="100%;">
<?php }
?>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-body">
<div class="comment_area">
</div>
<div class="media pt-2 px-3 border-top">
<img src="img/4.png" height="35px" width="35px" class="rounded-circle">
<div class="media-body">
<input type="hidden" class="post_id" value="<?php echo $id?>">
<input class="comment_box ml-2" placeholder="Write a comment..."></input>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('.comment_box').change(function(){
var comment=$(this).val();
var post_id=$('.post_id').val();
$.ajax({
url:"comment/insert.php",
type:"POST",
data:{comment,post_id},
success:function(){
$('.comment_box').val("");
}
})
})
$(document).ready(function(){
$('.comment_area').load('comment/select.php');
commentRefresh();
})
function commentRefresh()
{
setTimeout(function() //javascript function to make loading in assign second
{
$('.comment_area').load('comment/select.php'); //load method for loading where you want
commentRefresh();
},1000);
}
</script>
</body>
</html>