-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
executable file
·91 lines (78 loc) · 2.76 KB
/
dashboard.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
<?php include("includes/dashheader.php") ?>
<?php
include("connection.php");
$userq = mysqli_query($connect,"SELECT interests FROM user WHERE id='$uid'");
$ud = mysqli_fetch_array($userq);
$interests = $ud["interests"];
$query = mysqli_query($connect,"SELECT LEFT(description, 300) AS description, title, category, id FROM problems ORDER BY id DESC");
?>
<h2>Problems</h2>
<?php
if(!empty($interests)){
$intarray = explode(",",$interests);
while($data = mysqli_fetch_array($query)){
if(in_array($data["category"],$intarray)){
?>
<div class="card">
<div class="card-header">
<?php echo $data["category"] ?>
</div>
<div class="card-body">
<h4 class="card-title"><?php echo $data["title"] ?></h4>
<p class="card-text"><?php echo $data["description"] ?>...<br/>
<a href="viewprob.php?id=<?php echo $data["id"] ?>">Read More</a></p>
<?php
$likeq = mysqli_query($connect,"SELECT id FROM favourites WHERE postid='".$data['id']."' AND favuser='$uid';");
$lirows = mysqli_num_rows($likeq);
if($lirows != 0){
?>
<a href="unlike.php?id=<?php echo $data["id"] ?>&callback=problems" class="btn btn-primary">Unlike</a>
<?php
} else {
?>
<a href="favourite.php?id=<?php echo $data["id"] ?>&callback=problems" class="btn btn-primary">Favourite</a>
<?php
}
?>
<a href="#" class="btn btn-primary">Share</a>
<a href="fork.php?id=<?php echo $data["id"] ?>" class="btn btn-primary">Fork Problem</a>
</div>
</div>
<?php
}
}
} else {
?>
<?php
while($data = mysqli_fetch_array($query)){
?>
<div class="card">
<div class="card-header">
<?php echo $data["category"] ?>
</div>
<div class="card-body">
<h4 class="card-title"><?php echo $data["title"] ?></h4>
<p class="card-text"><?php echo $data["description"] ?>...<br/>
<a href="viewprob.php?id=<?php echo $data["id"] ?>">Read More</a></p>
<?php
$likeq = mysqli_query($connect,"SELECT id FROM favourites WHERE postid='".$data['id']."' AND favuser='$uid';");
$lirows = mysqli_num_rows($likeq);
if($lirows != 0){
?>
<a href="unlike.php?id=<?php echo $data["id"] ?>&callback=problems" class="btn btn-primary">Unlike</a>
<?php
} else {
?>
<a href="favourite.php?id=<?php echo $data["id"] ?>&callback=problems" class="btn btn-primary">Favourite</a>
<?php
}
?>
<a href="#" class="btn btn-primary">Share</a>
<a href="fork.php?id=<?php echo $data["id"] ?>" class="btn btn-primary">Fork Problem</a>
</div>
</div>
<?php
}
?>
<?php } ?>
<?php include("includes/dashfooter.php") ?>