-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathteaminsert.php
87 lines (74 loc) · 1.83 KB
/
teaminsert.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
<?php
$line = "";
$counter = 0;
$decide = 0;
include "header.php";
$sql = "SELECT * FROM `hold` where `HoldNavn` = '".$_POST['nytnavn']."'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$teamid = $row['ID'];
}
$sql = "SELECT * FROM `tournering` WHERE `ID` = '".$_GET['id']."'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$line = $row['HoldID'];
}
if(!empty($line)) {
$line .= ",".$teamid;
}
else {
$line .= $teamid;
}
$id = $_GET['id'];
$sql = "UPDATE `tournering` SET `HoldID`='".$line."' WHERE ID = '".$id."'";
if ($conn->query($sql) === TRUE ) {
$error = 1;
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$sql = "SELECT * FROM `tournering` WHERE `ID` = '".$_GET['id']."'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$counter1 = explode(",",$row['match1']);
$counter2 = explode(",",$row['match2']);
$counter3 = explode(",",$row['match3']);
$counter4 = explode(",",$row['match4']);
if (count($counter1) < 2 ) {
$decide = 1;
}
else if (count($counter2) < 2) {
$decide = 2;
}
else if (count($counter3) < 2 ) {
$decide = 3;
}
else if (count($counter4) < 2) {
$decide = 4;
}
else {
$decide = 1;
}
$line2 ="";
if (!empty($row['match'.$decide])) {
$line2 = $row['match'.$decide];
}
}
if (empty($line2)) {
$line2 = $_POST['nytnavn'];
}
else {
$line2 .= ",".$_POST['nytnavn'];
}
$sql = "UPDATE `tournering` SET `match".$decide."`='".$line2."' WHERE ID = '".$id."'";
if ($conn->query($sql) === TRUE ) {
$error = 1;
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
header('Location: index.php');
?>
<?php
include "footer.php";
?>