-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeetStats.php
More file actions
139 lines (89 loc) · 2.61 KB
/
Copy pathmeetStats.php
File metadata and controls
139 lines (89 loc) · 2.61 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
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
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="description" content="">
<meta charset="utf-8">
<meta name = "viewport" content = "user-scalable=yes, width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Cross Country Result Summary</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<style>
html, body {
/*height:100%;*/
margin:10;
padding:0;
height: 100vh;
}
</style>
<script>
</script>
</head>
<body>
<?php
//header('Content-type: text/plain');
require("../../conn1.php");
$mysqli = new mysqli($hostname, $username, $password, $database);
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
$table = "crossCountryResults";
/*
$sql = "SELECT * FROM $table WHERE minutes < 1";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$name = $row["name"];
$timeRaw = $row["timeRaw"];
$pid = $row["pid"];
list ($minutes, $sec) = split(":", $timeRaw );
$secondsTotal = ($minutes * 60) + $sec;
$timeDec = $secondsTotal/60;
// print $name." ".$minutes."-".$sec."=".$secondsTotal."<br>";
$sql2 = "UPDATE $table SET minutes='$minutes', sec='$sec', secondsTotal=$secondsTotal, timeDec = $timeDec WHERE pid=$pid";
$mysqli->query($sql2);
}
}
*/
//Get Median time of Top 10
$n = 10;
$raceArray = array('V_Girls', 'V_Boys', 'JH_Girls', 'JH_Boys');
$yearArray = array('2015', '2016', '2017', '2018');
$nArray = array(10, 50);
foreach ($raceArray as $race) {
print "<br><strong>$race </strong><br>";
foreach ($yearArray as $year) {
print "<br><strong>$year </strong><br>";
foreach ($nArray as $n) {
//for ($x = 1; $x < 5; $x++) {
$totalTime = 0;
$sql = "SELECT * FROM $table WHERE race = '$race' AND place <= $n AND year = '$year' ORDER By place";
$result = $mysqli->query($sql);
//race = 'V_Boys' AND place < 11 ORDER By rid
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$name = $row["name"];
$place = $row["place"];
$timeDec = $row["timeDec"];
$year = $row["year"];
$totalTime = $totalTime + $timeDec;
//print $year." ".$place." ".$name.", ".$timeDec."<br>";
}
}
//print "Total Time: ".$totalTime."<br>"
$avgDecimal = $totalTime/$n;
//print "<br>Average Time (Decimal): ".$avgDecimal."<br>";
$whole = floor($n);
$whole = floor($avgDecimal);
$sec = $avgDecimal - $whole;
$sec = $sec*60;
print "Average Top $n: ".$whole.":".$sec."<br>";
}
}
}
$mysqli->close();
?>
</body>
</html>