-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplace.php
61 lines (39 loc) · 1.3 KB
/
place.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
<!DOCTYPE html>
<?php session_start();
include 'connect.php'; //contains the values of the variables $host $dbname $user and $password
$con = pg_connect("host='" . $host . "' dbname='" . $dbname . "' user='" . $user . "' password='" . $password . "'");
if (!$con)
{
die("Could not connect: " . pg_last_error());
}
include('header.php');
include('functions.php');
echo "<h1>Scheduling Management</h1>";
if ( isset($_SESSION['msg']) ) {
echo "<br />" . $_SESSION['msg'];
$_SESSION['msg'] = "";
}
?>
<a href="manage.php">Return</a>
<?php
average_rank();
$info = info_array();
//Pull out array $srank_ar from $info
foreach ($info as $key => $row) {
$srank_ar[$key] = $row['srank'];
}
array_multisort($srank_ar, SORT_DESC, $info); //apply same order resulting from sorting ranks high to low to info
$count = 3;
$desks = array("w", "m", "d");
reset($info);
foreach($info as $pid=>$row){
if($info[$pid]['position'] == "DR"){
$sql = "UPDATE info SET desk ='" . $desks[$count%3] . "' WHERE pid='" . intval($pid) . "'";
pg_query($sql);
$count++;
}
}
echo "<br/><h4>Deskies have been placed.</h4><br/>";
unset($_SESSION['option']); //Unsets the option variable so that a refresh will not repeat the action
include('footer.php');
?>