-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrittenScore.php
143 lines (117 loc) · 2.95 KB
/
writtenScore.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
<?php $dir = ""; include($dir . "header.php"); ?>
<h1>Writtens</h1>
<style media="screen">
table {
font-family: arial, sans-serif;
border-collapse: collapse;
margin-bottom: 3em;
margin-top: 3em;
}
td,th {
/* border: 1px dashed #aaa; */
text-align: center;
padding: 1em;
overflow: auto;
}
tr:nth-child(even) {
background-color: #ccc;
}
#members{
width: 20%;
margin: 0 auto;
}
#members td,th{
border: 1px dashed #aaa;
}
#rankings{
width: 10%;
}
#rankings td,th{
border: 3px dotted #ddd ;
}
.writtenEdit{
width: 50px;
}
</style>
<?php
if(isset($_POST['sub'])) {
$servername = "localhost";
$username = "root";
$password = "admin";
$dbname = "cscomp";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//display members already in databse
$sql = "UPDATE members SET writtenScore = '".$_POST['written']."' WHERE name='".$_POST['member']."';";
$result = mysqli_query($conn,$sql);
header("Location: writtenScore.php");
}
$servername = "localhost";
$username = "root";
$password = "admin";
$dbname = "cscomp";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//display members already in databse
$sql = "SELECT * FROM members ORDER BY (CASE WHEN writtenScore IS NULL THEN 1 ELSE 0 END) DESC, writtenScore DESC;";
$result = mysqli_query($conn,$sql);
if($result->num_rows>0){
echo "<form action = 'writtenScore' method = 'POST'>";
echo "<center><input type = 'text' name = 'member' style = 'margin-right:10px;margin-bottom:50px;'>";
echo "<input class = 'writtenEdit' type = 'number' name = 'written' style = 'margin-right:10px;'>";
echo "<input type = 'submit' name = 'sub' value='Update'></center>";
echo "<table id = 'members'><caption>Competitors</caption>
<th>
Name
</th>
<th>
Written Score
</th>
<th>
Team
</th>
<th>
School
</th>
<th>
Level
</th>
";
while($row =mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$row['name']."</td>";
if($row['writtenScore']==null){
echo "<td> -- </td>";
}
else {
echo "<td>".$row['writtenScore']."</td>";
// echo "<td>".$row['writtenScore']."</td>";
}
echo "<td>".$row['team']."</td>";
$sql = "SELECT * FROM teams where username='".$row['team']."';";
$result1 = $conn->query($sql);
while($row1 = $result1->fetch_assoc()) {
echo "<td>".$row1['school']."</td>";
if($row1['level']=='nov'){
echo "<td>Novice</td>";
}
else{
echo "<td>Advanced</td>";
}
}
echo "</tr>";
}
echo "</table>";
echo "</form>";
}
?>