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
/
division_rem.php
60 lines (57 loc) · 1.61 KB
/
division_rem.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
<? 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 division 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("Division does not exist\n");
return;
}
$item = mysqli_fetch_array($result);
$squery = "SELECT s.name FROM division d JOIN season s ON (s.division = d.id) WHERE s.division='$id'";
$sresult = mysqli_query($link,$squery);
if(!$sresult) {
show_error("MySQL error: " . mysqli_error($link) . "\n");
return;
}
if(mysqli_num_rows($sresult) > 0) {
$seasons = "";
while($s = mysqli_fetch_array($sresult)) {
$seasons .= "• " . $s['name'] . "\n";
}
show_error("Division cannot be deleted because it is related to the following season(s):\n" . $seasons);
return;
}
?>
<h1>Delete division</h1>
<form action="division_rem_do.php" method="post">
<table border="0">
<tr>
<td width="120">Name:</td>
<td><?=$item['name']?></td>
</tr>
<tr>
<td>Type:</td>
<td><?=$item['type']?></td>
</tr>
<tr>
<td> </td>
<td>Are you sure that you want to delete this division?</td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="id" value="<?=$id?>">
<input type="submit" class="button submit" value="Yes">
<input type="button" class="button cancel" value="No" onclick="history.go(-1);">
</td>
</tr>
</table>
</form>