-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
42 lines (34 loc) · 1.3 KB
/
Copy pathdatabase.php
File metadata and controls
42 lines (34 loc) · 1.3 KB
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
<?php
$link = mysqli_connect("localhost", "root", "password", "ims");
if(!$link){
die("Some fucking error while connecting to the database");
}
if (!$link->set_charset("utf8")) {
die("Error loading character set utf8: ".$link->error);
}
function whoHasJob($free){
$link = $GLOBALS['link'];
$query = "SELECT `NoE` FROM `settings` WHERE `id` = 1";
$temp = mysqli_query($link, $query);
$temp1 = mysqli_fetch_assoc($temp);
$max = 0;
$person = 0;
for($i = 0; $i < $temp1['NoE']; $i++){
$query = "SELECT * FROM `tasks` WHERE `person`=$i";
$temp = mysqli_query($link, $query);
if(mysqli_num_rows($temp) > $max){
$max = mysqli_num_rows($temp);
$person = $i;
}
}
if($max > 1){
$query = "SELECT `id` FROM `tasks` WHERE `person`=$person ORDER BY `id` DESC LIMIT 1";
$temp = mysqli_query($link, $query);
$temp1 = mysqli_fetch_assoc($temp);
$query = "UPDATE `tasks` SET `person`=$free WHERE `id`=".$temp1['id'];
if(!mysqli_query($link, $query)){
die("Meh, something fucked up again,".$query);
}
}
}
?>