-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscussionDetails.php
223 lines (180 loc) · 5.5 KB
/
discussionDetails.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
//session_start();
require 'dbconfig/config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Farmer</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<link href="css/homepage.css" rel="stylesheet">
<!--<script>
$(document).ready(function(){
setInterval(function() {
$("#comment-body").load("loadComments.php");
}, 1000);
});
</script>-->
</head>
<body>
<?php include 'header.php';
$GLOBALS['forumid']="";
?>
<section id="main">
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<?php include 'sidebar-farmer.php'; ?>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class = "col-md-12">
<?php
require 'dbconfig/config.php';
?>
<?php
$forumid = $_GET['id'];
$forumID = $_GET['id'];
$sql="SELECT * FROM discussionforum WHERE Forum_ID = '$forumID'";
$date = "";
$time = "";
$username = "";
$category = "";
$topic = "";
$post = "";
$res=mysqli_query($con,$sql) or die(mysqli_error($con));
if($res)
{
while($row=mysqli_fetch_row($res))
{
$username = $row[1];
$date = $row[2];
$time = $row[3];
$category = $row[4];
$topic = $row[5];
$post = $row[6];
}
}
echo "
<p class='pull-right'>Date : $date<br>Time: $time</p>
<p>Category : $category</p>
<p>Topic : $topic</p>
<p>Post : $post</p>
";
/*
$sql = "SELECT * FROM order_details WHERE order_No = $ordNo";
$res=mysqli_query($con,$sql)
or die(mysqli_error($con));
if ($res){
while($row=mysqli_fetch_row($res)){
echo "<div class='tbl'>";
//echo "<table border=0>
echo "<tr>
<td>$row[2]</td>
<td>$row[3]</td>
</tr>";
echo "</div>";
}
echo"</table>";
echo "</div>";
echo "</div>";
}else{
echo "error".mysql_error();
}*/
?>
<form method="POST" action="insertComments.php?id=<?php echo $forumid?>" accept-charset="UTF-8">
<textarea rows="5" id="new-review" class="form-control animated" placeholder="Enter your review here..." name="comment" cols="50"></textarea><br>
<div class="text-right">
<button name="commentButton" class="btn btn-success btn-green" type="submit">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body" id = "comment-body">
<?php getComments($_GET['id']);?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
function getComments($forumID)
{
require("dbconfig/config.php");
//$res2=mysqli_query($con,$sql2);
/*if (isset($_GET["page"]))
{
$page = $_GET["page"];
}
else
{
$page=1;
};
$start_from = ($page-1) * $results_per_page;*/
//$sql2 = "SELECT * FROM paddyreview WHERE paddyID= '$paddyID' LIMIT $start_from, ".$results_per_page;
$sql2 = "SELECT * FROM discussiondetails WHERE forumID= '$forumID' ORDER BY commentID DESC";
$rs_result2 = mysqli_query($con,$sql2);
$count = 0;
while($row2 = mysqli_fetch_row($rs_result2))
{
echo "<div class='row'>
<div class='col-md-12'>";
echo $row2[2];
echo "<span class='pull-right'>$row2[3]<br>$row2[4]</span>";
//echo "<span class='pull-right'>$row2[4]</span>";
echo "<p>".$row2[5]."</p>";
echo "</div>
</div>
<hr>";
}
}
?>
<?php
/*if(isset($_POST['commentButton']))
{
require("dbconfig/config.php");
$un = "Anonymous";
$forID = $_GET['id'];
$comment = $_POST['comment'];
$date = date("Y-m-d");
$time = date("h:i:sa");
$query = "SELECT commentID FROM discussiondetails";
$query_run = mysqli_query($con,$query);
$oldno = mysqli_num_rows($query_run);
$newno = (string)($oldno + 1);
$prefix = "COM";
$newid = $prefix.$newno;
$sql5="INSERT INTO discussiondetails VALUES('$newid','$forID','$un','$date','$time','$comment')";
$res5=mysqli_query($con,$sql5);
//header("location:discussiondetails.php?id=$forumid");
}*/
?>
<!--<script>
function ajaxCall() {
$.ajax({
url: "loadComments.php",
success: (function (result) {
$("#comment-body").html(result);
})
})
};
ajaxCall(); // To output when the page loads
setInterval(ajaxCall, (2 * 1000)); // x * 1000 to get it in seconds
</script>-->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>