This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
season_chg.php
141 lines (132 loc) · 3.68 KB
/
season_chg.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
<? if(!defined("CONFIG")) exit(); ?>
<? if(!isset($login)) { show_error("You do not have administrator rights\n"); return; } ?>
<?
$id = addslashes($_GET['id']);
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$query = "SELECT * FROM season WHERE id='$id'";
$result = mysqli_query($link,$query);
if(!$result) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($result) == 0){
show_error("Season does not exist\n");
return;
}
$item = mysqli_fetch_array($result);
$diquery = "SELECT * FROM division ORDER BY name ASC";
$diresult = mysqli_query($link,$diquery);
if(!$diresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
$rsquery = "SELECT * FROM point_ruleset ORDER BY name ASC";
$rsresult = mysqli_query($link,$rsquery);
if(!$rsresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($rsresult) == 0) {
show_error("There are no rulesets.\n<a href=\"?page=point_add\">Add one</a> first.\n");
return;
}
$tquery = "SELECT * FROM team ORDER BY name ASC";
$tresult = mysqli_query($link,$tquery);
if(!$tresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($tresult) == 0) {
show_error("There are no teams.\n<a href=\"?page=team_add\">Add one</a> first.\n");
return;
}
$team = array();
while($titem = mysqli_fetch_array($tresult)) {
$team[$titem['id']] = $titem['name'];
}
function show_team_combo($tid = 0) {
global $team;
echo "<select name=\"team[]\">\n";
echo "<option value=\"\"> </option>\n";
foreach($team as $id => $tname) {
echo "<option value=\"$id\"";
if($tid == $id) echo " selected";
echo ">$tname</option>\n";
}
echo "</select>\n";
}
$stquery = "SELECT * FROM season_team WHERE season='$id'";
$stresult = mysqli_query($link,$stquery);
if(!$stresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
?>
<h1>Modify season</h1>
<form action="season_chg_do.php" method="post">
<table border="0">
<tr>
<td width="120">Name:</td>
<td><input type="text" name="name" value="<?=$item['name']?>" maxlength="20"></td>
</tr>
<tr>
<td>Division:</td>
<td>
<select name="division">
<? while($diitem = mysqli_fetch_array($diresult)) { ?>
<option value="<?=$diitem['id']?>"<?=($diitem['id'] == $item['division']) ? " selected" : ""?>><?=$diitem['name']?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Ruleset:</td>
<td>
<select name="ruleset">
<? while($rsitem = mysqli_fetch_array($rsresult)) { ?>
<option value="<?=$rsitem['id']?>"<?=($rsitem['id'] == $item['ruleset']) ? " selected" : ""?>><?=$rsitem['name']?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Ruleset qualifying:</td>
<td>
<select name="ruleset_qualifying">
<? mysqli_data_seek($rsresult, 0); ?>
<option value="0"> </option>
<? while($rsitem = mysqli_fetch_array($rsresult)) { ?>
<option value="<?=$rsitem['id']?>"<?=($rsitem['id'] == $item['ruleset_qualifying']) ? " selected" : ""?>><?=$rsitem['name']?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Max teams:</td>
<td><input type="text" name="maxteams" maxlength="3" size="2" value="<?=$item['maxteams']?>"></td>
</tr>
<tr>
<td>Teams:</td>
<td>
<?
for($x = 0; $x < $item['maxteams']; $x++) {
if($stitem = mysqli_fetch_array($stresult))
show_team_combo($stitem['team']);
else
show_team_combo();
echo "<br>\n";
}
?>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="id" value="<?=$id?>">
<input type="submit" class="button submit" value="Modify">
<input type="button" class="button cancel" value="Cancel" onclick="history.go(-1);">
</td>
</tr>
</table>
</form>