This repository has been archived by the owner on Sep 5, 2021. It is now read-only.
forked from avs-code/PREM-Podium-race-E-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrace_add.php
173 lines (167 loc) · 4.79 KB
/
race_add.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<? if(!defined("CONFIG")) exit(); ?>
<? if(!isset($login)) { show_error("You do not have administrator rights\n"); return; } ?>
<?
$season = $_GET['season'];
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$squery = "SELECT s.*, d.name dname FROM season s JOIN division d ON (d.id = s.division)";
$sresult = mysqli_query($link,$squery);
if(!$sresult) {
show_error("MySQL error: " . mysqli_error($link));
return;
}
$dquery = "SELECT * FROM division";
$dresult = mysqli_query($link,$dquery);
if(!$dresult) {
show_error("MySQL error: " . mysqli_error($link));
return;
}
$rquery = "SELECT id, name FROM point_ruleset";
$rresult = mysqli_query($link,$rquery);
if(!$rresult) {
show_error("MySQL error: " . mysqli_error($link));
return;
}
?>
<h1>Add race</h1>
<form action="race_add_do.php" method="post">
<table border="0">
<tr>
<td width="120">Name:</td>
<td><input type="text" name="name" maxlength="30"></td>
</tr>
<tr>
<td>Track:</td>
<td><input type="text" name="track" maxlength="30"></td>
</tr>
<tr>
<td>image_link:</td>
<td><input type="url" name="imagelink" maxlength="200"></td>
</tr>
<tr>
<td>Laps:</td>
<td><input type="text" name="laps" maxlength="3" size="3"></td>
</tr>
<tr>
<td>Season:</td>
<td>
<select id="season" name="season" onchange="showOptions();">
<option value="0">--NO SEASON--</option>
<? while($sitem = mysqli_fetch_array($sresult)) { ?>
<option value="<?=$sitem['id']?>"<?=$season == $sitem['id'] ? " selected=\"1\"" : ""?>><?=$sitem['name']?> (<?=$sitem['dname']?>)</option>
<? } ?>
</select>
</td>
</tr>
<tr id="diff_ruleset">
<td>Different ruleset:</td>
<td><input id="chk_diff_ruleset" name="diff_ruleset" type="checkbox" onchange="showOptions();"/></td>
</tr>
<tr id="division">
<td>Division:</td>
<td>
<select name="division" onchange="void(0);">
<? while($ditem = mysqli_fetch_array($dresult)) { ?>
<option value="<?=$ditem['id']?>"><?=$ditem['name']?> (<?=$ditem['type']?>)</option>
<? } ?>
</select>
</td>
</tr>
<tr id="ruleset">
<td>Ruleset:</td>
<td>
<select name="ruleset" onchange="void(0);">
<? while($ritem = mysqli_fetch_array($rresult)) { ?>
<option value="<?=$ritem['id']?>"><?=$ritem['name']?></option>
<? } ?>
</select>
</td>
</tr>
<tr id="ruleset_qualifying">
<td>Ruleset qualifying:</td>
<td>
<select name="ruleset_qualifying" onchange="void(0);">
<? mysqli_data_seek($rresult, 0); ?>
<option value=""> </option>
<? while($ritem = mysqli_fetch_array($rresult)) { ?>
<option value="<?=$ritem['id']?>"><?=$ritem['name']?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Date:</td>
<td>
<select name="day">
<? for($x = 1; $x <= 31; $x++) { ?>
<option<?=date("j") == $x ? " selected" : ""?>><?=sprintf("%02d", $x)?></option>
<? } ?>
</select>
<select name="month">
<? $months = array(1 => "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?>
<? for($x = 1; $x <= 12; $x++) { ?>
<option<?=date("n") == $x ? " selected" : ""?> value="<?=$x?>"><?=$months[$x]?></option>
<? } ?>
</select>
<select name="year">
<? for($x = 2000; $x <= 2050; $x++) { ?>
<option<?=date("Y") == $x ? " selected" : ""?>><?=sprintf("%04d", $x)?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Time:</td>
<td>
<select name="hour">
<? for($x = 0; $x <= 23; $x++) { ?>
<option<?=$x == "12" ? " selected" : ""?>><?=sprintf("%02d", $x)?></option>
<? } ?>
</select> :
<select name="minute">
<? for($x = 0; $x <= 59; $x = $x + 5) { ?>
<option><?=sprintf("%02d", $x)?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Max players:</td>
<td><input type="text" name="maxplayers" maxlength="3" size="3" value="20"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" class="button submit" value="Add">
<input type="button" class="button cancel" value="Cancel" onclick="history.go(-1);">
</td>
</tr>
</table>
</form>
<script type="text/javascript" language="javascript" src="functions.js"></script>
<script type="text/javascript" language="javascript">
<!--
function showOptions() {
var season = ele("season").value;
var chk_diff_ruleset = ele("chk_diff_ruleset").checked;
if(season == 0) {
ele("diff_ruleset").style.display = "none";
ele("division").style.display = "table-row";
ele("ruleset").style.display = "table-row";
ele("ruleset_qualifying").style.display = "table-row";
}
else {
ele("diff_ruleset").style.display = "table-row";
ele("division").style.display = "none";
if(chk_diff_ruleset) {
ele("ruleset").style.display = "table-row";
ele("ruleset_qualifying").style.display = "table-row";
} else {
ele("ruleset").style.display = "none";
ele("ruleset_qualifying").style.display = "none";
}
}
}
showOptions();
// -->
</script>