-
Notifications
You must be signed in to change notification settings - Fork 1
/
searchValidity.php
146 lines (131 loc) · 4.9 KB
/
searchValidity.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">
<?php
include 'TBAdata.php';
$matchNum = $_GET['matchnum'];
$matchSet = $_GET['set'];
$teamnum[0] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 1, 0);
$teamnum[1] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 1, 1);
$teamnum[2] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 1, 2);
$teamnum[3] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 2, 0);
$teamnum[4] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 2, 1);
$teamnum[5] = getTeam($GLOBALS['TBA']['MATCH_TYPE'], $matchSet, $matchNum, 2, 2);
$msqlcon = mysqli_connect("localhost","data","mxwZsnKw5FtD8uX8","sandman");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//echo "Command: SELECT * FROM `matchdata` WHERE matchNum = " . $matchNum . " AND teamNum = " . "$teamnum[1]";
$result[0] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[0]");//R1
$result[1] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[1]");//R2
$result[2] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[2]");//R3
$result2[0] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[3]");//B1
$result2[1] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[4]");//B2
$result2[2] = mysqli_query($msqlcon, "SELECT * FROM `matchdata` WHERE matchNum = $matchNum AND teamNum = $teamnum[5]");//B3
echo "<h3 style='text-align:center'><b>WIP</b></h3><br>
<h1 style='text-align:center'><u>Collected Data</u></h1><br>
<h2 style='text-align:center'><u>Blue Alliance</u></h1><br>
<div class='container'>
<table class='table table-striped'>
<thead>
<tr>
<th>Team</th>
<th>Auto Gears</th>
<th>Auto Baseline</th>
<th>Auto kPa</th>
<th>Teleop Gears</th>
<th>Teleop kPa</th>
<th>Climb</th>
</tr>
</thead>
<tbody>";
teamTable($result);
// foreach($result as $key => $value){
// if ($value == NULL){
// echo "<tr><td>No data</td></tr>";
// continue;
// }
// $row = mysqli_fetch_array($value);
// echo "<tr>
// <td>" . $teamnum[$key] . "</td>
// <td>" . checkX($row['autoCap.gearSuccess']) . "</td>
// <td>" . checkX($row['autoCap.passBaseline']) . "</td>
// <td>" . $row['autoCap.KPA'] . "</td>
// <td>" . $row['teleCap.gearSuccess'] . "</td>
// <td>" . $row['teleCap.KPA'] . "</td>
// <td>" . checkX($row['teleCap.climb']) . "</td>
// </tr>";
// }
echo "</tbody>
</table>";
summary($result);
echo "</div>";
function checkX($bool){
if ($bool) {
return "<i class='fa fa-check' aria-hidden='true'></i>";
}else {
return "<i class='fa fa-times' aria-hidden='true'></i>";
}
}
function teamTable($rs){
foreach($rs as $key => $value){
if ($value == NULL){
echo "<tr><td>No data</td></tr>";
continue;
}
$row = mysqli_fetch_array($value);
echo "<tr>
<td>" . $teamnum[$key] . "</td>
<td>" . checkX($row['autoCap.gearSuccess']) . "</td>
<td>" . checkX($row['autoCap.passBaseline']) . "</td>
<td>" . $row['autoCap.KPA'] . "</td>
<td>" . $row['teleCap.gearSuccess'] . "</td>
<td>" . $row['teleCap.KPA'] . "</td>
<td>" . checkX($row['teleCap.climb']) . "</td>
</tr>";
}
}
function summary($rs){
echo "<h3 style = 'text-align:center'>Team Summary</h3><br>
<table class = 'table table-bordered'>
<thead>
<tr>
<th>Auto Gears</th>
<th>Auto Baseline</th>
<th>Auto kPa</th>
<th>Teleop Gears</th>
<th>Teleop kPa</th>
<th>Climb</th>
</tr>
</thead>
<tbody>";
$autoGears = 0;
$autoBaseline = 0;
$autokPa = 0;
$teleGears = 0;
$telekPa = 0;
$climb = 0;
foreach($rs as $key => $value){
if ($value == NULL){
continue;
}
$r = mysqli_fetch_array($value);
$autoGears += $r['autoCap.gearSuccess'];
echo "autoGears = " . $r['autoCap.gearSuccess'] . ", ";
$autoBaseline += $r['autoCap.passBaseline'];
$autokPa += $r['autoCap.KPA'];
$teleGears += $r['teleCap.gearSuccess'];
$telekPa += $r['teleCap.KPA'];
$climb += $r['teleCap.climb'];
}
echo "<tr>
<td>" . $autoGears . "</td>
<td>" . $autoBaseline . "</td>
<td>" . $autokPa . "</td>
<td>" . $teleGears . "</td>
<td>" . $telekPa . "</td>
<td>" . $climb . "</td>
</tr>
</tbody>
</table>";
}
?>