forked from if-itb/IF3110-2015-T1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer.php
89 lines (55 loc) · 3.01 KB
/
answer.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="questionStyle.css"/>
<script type="text/javascript" src="ValidasiInputAnswer.js"></script>
<title>Answer</title>
</head>
<body>
<div class="container">
<div id="header" > <a class="link1" href="home.php"> Simple StackExchange </div> </a>
<?php
include("dataBase.php");
$ID = htmlspecialchars($_GET['id']);
$input = "SELECT ID, Vote, Name, Email, Topic, Content, Date_Create FROM questions WHERE ID = $ID";
$question = mysqli_query($conn, $input);
$output = "SELECT ID, Vote, Name, Email, Content, Date_Create FROM answers WHERE Quest_ID = $ID";
$answer = mysqli_query($conn, $output);
include("EditAnswer.php");
echo "<script type = \"text/javascript\" src = \"vote.js\"> </script>";
if(mysqli_num_rows($question) > 0 ) {
while ($row = mysqli_fetch_assoc($question)){
echo "<div> <div class=header2 id=main3> ".$row["Topic"]."</div> ";
echo "<span> <div class = arrow-up id = QU".$row["ID"]." name=vote onclick = vote(this.id)> </div> ";
echo "<div class = votes > <div id=Q".$row["ID"]." class=votes-counts>".$row["Vote"]."</div> ";
echo" <div class=content1> <div class=content2>" .$row["Content"]."</div> </div> </span> ";
echo "<div class = arrow-down id = QD".$row["ID"]." name=vote onclick = vote(this.id)> </div> ";
echo "<div class=asked1> asked by " .$row["Name"]." at " .$row["Date_Create"]." | <a href=edit.php?id=".$row["ID"]. " class=link > edit </a> | <a onclick=\"return confirm('Are you sure want to delete this question?')\" href=DeleteQuestion.php?id=".$row["ID"]. " class=link2> delete <a> </div>";
}
echo "<div class=header2 id=main3>".mysqli_num_rows($answer)." Answer </div>";
}
if(mysqli_num_rows($answer) > 0 ) {
while ($row = mysqli_fetch_assoc($answer)){
echo "<div id =AU".$row["ID"]." name=vote onclick = vote(this.id) class = arrow-up> </div> ";
echo "<div class = votes > <div id= A".$row["ID"]." class=votes-counts >".$row["Vote"]."</div>";
echo "<div class=content1> <div class=content2>" .$row["Content"]."</div> </div>";
echo "<div id = AD".$row["ID"]." name=vote onclick = vote(this.id) class = arrow-down> </div> ";
echo "<div class=asked2> answer by " .$row["Email"]." at " .$row["Date_Create"]. "</div>";
echo "<div class=garis> </div>";
//echo "<div class=header2 id=main3>".mysqli_num_rows($answer)."Answer </div>";
}
echo "<br>";
}
echo " <div id=main4> Your Answer </div>
<form name=ask onsubmit= \"return ValidasiInputAnswer()\" action=answer.php?id=" .$ID." method=post>
<input type=text name=name placeholder=Name class=header3 >
<input type=text name=email placeholder=Email class=header3 >
<textarea type=text name=content placeholder=Content class=header3 id=content value=></textarea>
<br> </br>
<button class = answer1 type=submit name=answer value=Post> Post </button>
</form>";
mysqli_close($conn);
?>
</div>
</body>
</html>