-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint_rem_do.php
47 lines (39 loc) · 1.61 KB
/
point_rem_do.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
<?php
/*
* point_rem_do.php Version 1.11.0.0
* date 05.05.19
*
*
*/
require_once("session_start.php");
if(!isset($login)) error("Du hast keine Administratorrechte");
$id = addslashes($_POST['id']);
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
$error = "";
$squery = "SELECT s.name, d.name division FROM season s JOIN division d ON (s.division = d.id) WHERE (s.ruleset='$id' OR s.ruleset_qualifying='$id')";
$sresult = mysqli_query($link,$squery);
if(!$sresult) error("MySQL error: " . mysqli_error($link) . "\n");
if(mysqli_num_rows($sresult) > 0) {
$seasons = "";
while($s = mysqli_fetch_array($sresult)) {
$seasons .= "• " . $s['name'] . " (" . $s['division'] . ")\n";
}
$error .= "Ruleset cannot be deleted because it is related to the following season(s):\n" . $seasons;
}
$rquery = "SELECT r.name, r.track FROM race r WHERE (r.ruleset='$id' OR r.ruleset_qualifying='$id') AND r.season='0'";
$rresult = mysqli_query($link,$rquery);
if(!$rresult) error("MySQL error: " . mysqli_error($link) . "\n");
if(mysqli_num_rows($rresult) > 0) {
$races = "";
while($r = mysqli_fetch_array($rresult)) {
$races .= "• " . $r['name'] . " (" . $r['track'] . ")\n";
}
$error .= "Ruleset cannot be deleted because it is related to the following race(s):\n" . $races;
}
if(!empty($error)) error($error);
$query = "DELETE FROM point_ruleset WHERE id='$id'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
return_do("blanc.php?page=points", "Punktesatz wurde entfernt . $msg");
?>