-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
executable file
·127 lines (107 loc) · 3.79 KB
/
profile.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
<?php include("includes/dashheader.php") ?>
<?php
include("connection.php");
$uid = $_SESSION["userid"];
//get points based on facourites
$points = 0;
$level = "";
$favpoints = mysqli_query($connect,"SELECT f.id, u.fullname FROM user AS u, favourites AS f, problems AS p WHERE u.id='$uid' AND p.uid=u.id AND f.postid=p.id AND f.favuser <> '$uid'");
$favptrows = mysqli_num_rows($favpoints);
$favdata = mysqli_fetch_array($favpoints);
$points = $points + ($favptrows * 10);
if($points < 500){
$level = "Beginner";
} else if($points < 1000){
$level = "Intermediate";
} else if($points < 5000){
$level = "Advanced";
} else if($points > 5000){
$level = "Expert";
}
?>
<div class="card">
<div class="card-header">
<h4><?php echo $favdata["fullname"] ?></h4>
</div>
<div class="card-body">
<table width="100%">
<tr>
<td>
<h4 class="card-title">POINTS:- <?php echo $points ?></h4>
<h4 class="card-title">LEVEL:- <?php echo $level ?></h4>
</td>
<td width="10%">
<img src="img/dummy.png" alt="" style="width:100px;"/>
</td>
</tr>
</table>
</div>
</div>
<h4>FORKED PROBLEMS</h4>
<?php
$forkedq = mysqli_query($connect,"SELECT LEFT(description, 300) AS description, title, category, id FROM problems WHERE uid='$uid' AND forkid <> '0'");
while($data = mysqli_fetch_array($forkedq)){
?>
<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=profile" class="btn btn-primary">Unlike</a>
<?php
} else {
?>
<a href="favourite.php?id=<?php echo $data["id"] ?>&callback=profile" class="btn btn-primary">Favourite</a>
<?php
}
?>
<a href="#" class="btn btn-primary">Share</a>
<a href="delete.php?id=<?php echo $data["id"] ?>&callback=profile" class="btn btn-primary">Delete Problem</a>
</div>
</div>
<?php
}
?>
<hr/>
<h4 style="margin-top:35px;">MY PROBLEMS</h4>
<?php
$forkedq = mysqli_query($connect,"SELECT LEFT(description, 300) AS description, title, category, id FROM problems WHERE uid='$uid' AND forkid = '0'");
while($data = mysqli_fetch_array($forkedq)){
?>
<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=profile" class="btn btn-primary">Unlike</a>
<?php
} else {
?>
<a href="favourite.php?id=<?php echo $data["id"] ?>&callback=profile" class="btn btn-primary">Favourite</a>
<?php
}
?>
<a href="#" class="btn btn-primary">Share</a>
<a href="delete.php?id=<?php echo $data["id"] ?>&callback=profile" class="btn btn-primary">Delete Problem</a>
</div>
</div>
<?php
}
?>
<?php include("includes/dashfooter.php") ?>