-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
categories.php
230 lines (214 loc) · 10.1 KB
/
categories.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
224
225
226
227
228
229
230
<?php
session_start();
include('connect.php');
if(isset($_POST["ansubmit"])){
function valid($data){
$data = trim(stripslashes(htmlspecialchars($data)));
return $data;
}
$answer = valid($_POST["answer"]);
if($answer == NULL){
echo "<script>window.alert('Please Enter something.');</script>";
}
else{
$que = "";
if($_POST["nul"]==0){
if(strpos($_POST["preby"],$_SESSION["user"]) === false)
$que = "update quans set answer=CONCAT(answer,'<br>or<br>".$_POST["answer"]."'), answeredby=CONCAT(answeredby,', @ ".$_SESSION["user"]."') where question like '%".$_POST["question"]."%'";
else
$que = "update quans set answer=CONCAT(answer,'<br>or<br>".$_POST["answer"]."'), answeredby = '".$_SESSION["user"]."' where question like '%".$_POST["question"]."%'";
}
else
$que = "update quans set answer='".$_POST["answer"]."', answeredby = '".$_SESSION["user"]."' where question like '%".$_POST["question"]."%'";
if(mysqli_query($conn,$que))
echo "<style>#box0,.open{display: none;} #tb{display: block;}</style>";
else
header("Location: index.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Interrogate </title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/material.css">
<link type="text/css" rel="stylesheet" href="fonts/font.css">
<link rel="icon" href="images/icon1.png" >
<!-- Sripts -->
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<style>
textarea{
display: none;
width: 300px;
height: 50px;
background: #333;
color: #ddd;
padding: 10px;
margin: 5px 0 -14px;
}
.ans_sub{
display: none;
padding: 0 10px;
height: 30px;
line-height: 30px;
}
.pop{
display: none;
text-align: center;
margin: 195.5px auto;
font-size: 12px;
}
</style>
</head>
<body id="_3">
<!-- navigation bar -->
<a href="index.php">
<div id="log">
<div id="i">i</div><div id="cir">i</div><div id="ntro">nterrogate</div>
</div>
</a>
<ul id="nav-bar">
<a href="index.php"><li>Home</li></a>
<a href="categories.php"><li id="home">Categories</li></a>
<a href="contacts.php"><li>Contact</li></a>
<a href="ask.php"><li>Ask Question</li></a>
<?php
if(! isset($_SESSION['user'])){
?>
<a href="login.php"><li>Log In</li></a>
<a href="signup.php"><li>Sign Up</li></a>
<?php
}
else{
?>
<a href="profile.php"><li>Hi, <?php echo $_SESSION["user"]; ?></li></a>
<a href="logout.php"><li>Log Out</li></a>
<?php
}
?>
</ul>
<!-- content -->
<div id="content">
<h4>
<a id="title-head" href="categories.php">Categories</a>
</h4>
<div id="box0">
<center>
<a id="ada" href="#box1">
<div id="algo" class="img">
<div id="p" title="Open">Algorithm</div>
</div>
</a>
<a id="cso" href="#box2">
<div id="archi" class="img">
<div id="p" title="Open">Architecture</div>
</div>
</a>
<a id="t" href="#box3">
<div id="toc" class="img">
<div id="p" title="Open">Theory of Computation</div>
</div>
</a>
</center>
<center>
<a id="db" href="#box4">
<div id="database" class="img">
<div id="p" title="Open">Database Management</div>
</div>
</a>
<a id="pqt" href="#box5">
<div id="prob" class="img">
<div id="p" title="Open">Probability & Queuing Theory</div>
</div>
</a>
<a id="se" href="#box6">
<div id="soft" class="img">
<div id="p" title="Open">Software Engineering</div>
</div>
</a>
</center>
</div>
<div class="pop" id="tb">
<center><h1><b style="font-size: 1.5em; margin: -60px auto 10px; display: block;">:)</b>Thank You For Your Answer.</h1></center>
</div>
<center>
<?php
$no = 1;
$n = 1;
$nul=0;
while($no < 7){
?>
<div id="box<?php echo $no; ?>" class="open">
<a href=""><div id="close">X</div></a>
<div id="topic">
<?php
echo "<h2 id='topic-head'>";
$q = 'select name, description from category where id='.$no;
$r = mysqli_query($conn,$q);
$d = mysqli_fetch_assoc($r);
echo $d['name'].'</h2><p id="topic-desc">'.$d['description']."<br>Explore our home page for more questions.</p>";
?>
</div>
<center>
<?php
$qu = "select q.question, q.answer, q.askedby, q.answeredby from quans as q, quacat as r, category as c where q.id=r.id and r.category=c.name and c.id='$no' Limit 8";
$re = mysqli_query($conn,$qu);
while($da = mysqli_fetch_assoc($re)){
?>
<div id="qa-block">
<div class="question">
<div id="Q">Q.</div>
<?php echo $da['question']."<small id='sml'>Asked By: @".$da['askedby']."</small>"; ?>
</div>
<div class="answer">
<?php
if($da["answer"]){
$nul=0;
echo $da["answer"]."<br><small>Answered By: @".$da['answeredby']."</small>";
}
else{
$nul=1;
echo "<em>*** Not Answered Yet ***</em>";
}
?>
<form id="f<?php echo $n; ?>" style="margin-bottom: -25px;" action="<?php echo htmlspecialchars( $_SERVER["PHP_SELF"] ); ?>" method="post" enctype="multipart/form-data">
<!-- <input type="button" value="Click here to answer." id="ans_b" >-->
<label style="margin-bottom: -25px;"><a id="ans_b<?php echo $n; ?>" href="#area<?php echo $no; ?>"><u>Submit your answer</u></a></label>
<br>
<script>
$(function(){
$('#ans_b<?php echo $n; ?>').click(function(e){
e.preventDefault();
$('#area<?php echo $n; ?>').css("display","block");
$('#ar<?php echo $n; ?>').css("display","block");
$('#f<?php echo $n; ?>').css("margin-bottom","0px");
});
});
</script>
<textarea id="area<?php echo $n; ?>" name="answer" placeholder="Your Answer..."></textarea>
<input style="display: none;" name="question" value="<?php echo $da['question'] ?>">
<input style="display: none;" name="nul" value="<?php echo $nul ?>">
<input style="display: none;" name="preby" value="<?php echo $da['answeredby'] ?>">
<br>
<input type="submit" name="ansubmit" value="Submit" class="up-in ans_sub" id="ar<?php echo $n; ?>">
</form>
</div>
</div>
<?php $n++; } ?>
</center>
</div><!-- box1 -->
<?php
$no++;
}
?>
</center>
</div><!-- content -->
<!-- Footer -->
<div id="footer">
© 2017 • Interrogate Inc.
</div>
</body>
</html>