-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.php
309 lines (237 loc) · 9.12 KB
/
homepage.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
session_start();
include 'config.php';
if($_SESSION['username'] =='admin')
header('Location: admin.php');
if(!isset($_SESSION['uid']))
{
header('Location: login.php');
}
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
<link href="https://fonts.googleapis.com/css?family=Rubik" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Timmana" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Ubuntu|Ubuntu+Condensed|Ubuntu+Mono" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<style>
body {
background-color: #FAFAFA;
}
.menu {
position: relative;
top: 0px;
width: 100%;
height: 50px;
border: solid 1px #DDDDDD;
}
.feeds {
float: left;
position: relative;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 25%;
padding-left:10%;
padding-top:50px;
background-color: #FAFAFA;
font-weight: 400;
font-size: 15px;
line-height: 25px;
color: #666666;
}
.feeds a
{
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-decoration:none;
font-weight: 400;
font-size: 15px;
line-height: 25px;
color: #666666;
}
.main {
float: left;
position:absolute;
left: 25%;
width: 50%;
background-color: #FAFAFA;
}
.ques_tab {
position: relative;
margin: 2%;
padding: 3%;
background-color: white;
width: 90%;
border: solid #E2E2E2 1px;
border-radius: 10px;
box-shadow: 1px 1px 1px #aaaaaa;
}
.question {
font-family: q_serif, "Georgia", Times, "Times New Roman", "Hiragino Kaku Gothic Pro", Meiryo, serif;
font-weight: 700;
font-size: 18px;
line-height: 23px;
color: #262626;
}
.ans {
font-size: 15px;
font-family: 'Ubuntu', sans-serif;
line-height: 24px;
font-weight: 400;
color: #333333;
outline:none;
}
.writer {
line-height: 18px;
}
.profile {
float: left;
position: absolute;
left: 75%;
width: 25%;
background-color: #FAFAFA;
}
.topic,
.time {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px;
line-height: 18px;
font-weight: 400;
color: #999999;
}
#down
{
float: right;
}
#up
{
float: left;
}
#up button,#down button
{
border:none;
background-color: Transparent;
outline:none;
}
#down :hover
{
font-size:15px;
}
#up :hover {font-size:15px;}
a{
text-decoration:none;
}
</style>
<body>
<div class="menu">
<?php include'menu.php';?>
</div>
<div class="feeds">
<h3>Feeds</h3><hr>
<ul>
<li>Topics</li>
<li><a href="topic.php?topic=Programming">Programming</a></li>
<li><a href="topic.php?topic=Science">Science</a></li>
<li><a href="topic.php?topic=books">Books</a></li>
<li><a href="topic.php?topic=economics">Economics</a></li>
<li><a href="topic.php?topic=movies">Movies</a></li>
<li><a href="topic.php?topic=music">Music</a></li>
<li><a href="topic.php?topic=sports">Sports</a></li>
<li><a href="topic.php?topic=gaming">Gaming</a></li>
<li><a href="topic.php?topic=food">Food</a></li>
<li><a href="topic.php?topic=travelling">Travelling</a></li>
<li><a href="group.php" >Goto your Group</a></li>
</ul>
</div>
<div class="main">
<?php
$uid=$_SESSION['uid'];
$sql="select * from interest where id=$uid";
$result=mysqli_query($db,$sql);
$row= mysqli_fetch_assoc($result);
$prefernum=array($row['programming'], $row['science'], $row['books'], $row['economics'], $row['movies'], $row['music'], $row['sports'], $row['gaming'], $row['food'], $row['travelling']);
$prefer=array('programming', 'science', 'books', 'economics', 'movies', 'music', 'sports', 'gaming', 'food', 'travelling');
for ($i=0; $i <sizeof($prefernum) ; $i++) {
if($prefernum[$i]==1)
{
$category="'".$prefer[$i]."'";
$sql="Select * from questions where category="."'".$prefer[$i]."' and area='open'";
$result=mysqli_query($db,$sql);
$qresults=mysqli_num_rows($result);
if($qresults>0)
{
while($row= mysqli_fetch_assoc($result))
{ $sqla='select * from answers where qid='.$row['qid'].' order by upvotes desc limit 1';
$resulta=mysqli_query($db,$sqla);
$qresultsa=mysqli_num_rows($resulta);
if($qresultsa>0)
{
echo '<div class="ques_tab"><div class="ques" ><span class="topic">'.$row["category"].'</span><br>
<a href="./question.php?question='.$row["qid"].'"> <span class="question" >'.$row["ques"].'</span></a><br>
<span class="writer">Written by:'.$row["author"].'</span><br>
<span class="time">'.$row["time"].'</span>';
$rowa=mysqli_fetch_assoc($resulta);
echo '<div class="ans" color="#333333">'.$rowa['answer']. ' </div><div id="up"><br><button class="upbut" id='.$rowa["aid"].' value=0><i class="fa fa-thumbs-o-up w3-text-indigo" style="font-size:20px;"></i> Upvote</button></div><br><br> </div> </div>';
}
}
}
}
}
?>
<!-- <div class="ques_tab">
<div class="ques"><span class="topic">Topic name</span><br>
<span class="question">How to make Quora?</span><br>
<span class="writer">Written by:</span><br>
<span class="time">19hrs ago</span>
<div class="ans">
<details>
<summary>Your character is cleaning their room. Or maybe your character isn’t one to clean. Maybe
your character is digging through their untidy drawers to find an item that they misplaced. For
whatever the reason is, your character stumbles across an old photograph. If your character is
in a state of peacefulness now, it would be best to have the photograph depict a more chaotic
time in their life. If the character’s life is currently in turmoil,</summary> it would be best
to have the photo depict a happier time. This will work well because not only will your character
dwell on a past period of their life, but they can compare that time to the present. Maybe the photograph
shows a better time; maybe because of this, the person is suddenly inspired to turn their life around.
Or perhaps the character sees the photograph of what he or she once viewed as a bad event in their
life, only to realize that it wasn’t as horrible as it seemed. Maybe they wish they could go back
to the day that the photo was taken, or maybe they wish to rip it to shreds. The possibilities are
endless.
</details>
</div><br>
<div id='up'><button id='upbut'><i class="fa fa-thumbs-o-up w3-text-indigo" style="font-size:20px;"></i> Upvote</button></div><div id='down'><button id='downbut'><i class="fa fa-thumbs-o-down w3-text-indigo" style="font-size:20px;"></i> Downvote</button></div><br>
</div>
</div>
</div>-->
<div class="profile"></div>
</body>
</html>
<script>
$(document).ready(function () {
$('button').click(function(){
var a=$(this).attr('value');
if (a==0)
{ console.log(this.id);
$(this).css({'color':'green','font-size':'15px'});
$(this).attr('value','1');
$.post("upvote.php",{aid:this.id,value:a},function(data,status){
console.log(count);
});
}
else
{
$(this).attr('value','0');
$.post("upvote.php",{aid:this.id,value:a},function(data,status){
console.log(count);
})
$(this).css({'color':'black','font-size':'15px'});
}
});
});
</script>