-
Notifications
You must be signed in to change notification settings - Fork 31
/
abayayhsgs.php
73 lines (69 loc) · 3.05 KB
/
abayayhsgs.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
<?php
include './config/connect.php';
//i don't know what i am writing tho, i hope it works sha
$first ="UPDATE `user` SET `score` = '0' WHERE `score` > 0";
$reset = mysqli_query($conn, $first);
$sql = "SELECT email FROM user";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if ($count > 0) {
while($row = mysqli_fetch_assoc($result)) {
$particular_user = $row['email'];
$up = total_score($particular_user);
update_total($particular_user, $up);
}
}
function total_score($email){
global $conn;
$queryURL = "SELECT `points` FROM submissions WHERE `user` = '$email' ";
$resultURL = mysqli_query($conn, $queryURL);
$countURL = mysqli_num_rows($resultURL);
$total = 0;
if ($countURL > 0) {
while($row = mysqli_fetch_assoc($resultURL)) {
$total += $row['points'];
}
return $total;
}else{
return $total;
}
}
function update_total($email, $total){
global $conn;
$query = "UPDATE user SET score = $total WHERE `email` = '$email' ";
$result = mysqli_query($conn, $query);
if($conn->query($query)){
return 1;
}else{
return 0;
}
}
// $email = $_SESSION['login_user'];
// $total = total_score($email);
// $sql = "UPDATE user SET `score` = '$total' WHERE `email` = '$email'";
// if(mysqli_query($conn, $sql)){
// echo 'successful';
// }
// else {
// echo 'error';
// }
// function totalRun($email){
// global $conn;
// $queryURL = "SELECT `user` FROM user WHERE isAdmin = 0";
// $resultURL = mysqli_query($conn, $queryURL);
// $countURL = mysqli_num_rows($resultURL);
// $total = 0;
// if ($countURL > 0) {
// while ($row=$resul->fetch_assoc()) {
// total_score($row['user']);
// }
// }
// }
/*
SELECT email, COUNT(email) FROM user GROUP BY email HAVING COUNT(email) > 1
INSERT INTO `submissions` (`id`, `user`, `track`, `url`, `task_day`, `comments`, `points`, `sub_date`, `feedback`) VALUES (NULL, '[email protected]', 'frontend', 'Twitter Points', 'March 28', 'Twitter Points', '5', 'March 28', 'GIVEN');
INSERT INTO `submissions` (`id`, `user`, `track`, `url`, `task_day`, `comments`, `points`, `sub_date`, `feedback`) VALUES (NULL, '[email protected]', 'frontend', 'Twitter Points', 'March 28', 'Twitter Points', '5', 'March 28', 'GIVEN');
INSERT INTO `submissions` (`id`, `user`, `track`, `url`, `task_day`, `comments`, `points`, `sub_date`, `feedback`) VALUES (NULL, '[email protected]', 'frontend', 'Twitter Points', 'March 28', 'Twitter Points', '5', 'March 28', 'GIVEN');
INSERT INTO `submissions` (`id`, `user`, `track`, `url`, `task_day`, `comments`, `points`, `sub_date`, `feedback`) VALUES (NULL, '[email protected]', 'python', 'Twitter Points', 'March 28', 'Twitter Points', '5', 'March 28', 'GIVEN');
*/
?>