-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_exp.php
More file actions
131 lines (119 loc) · 4.73 KB
/
update_exp.php
File metadata and controls
131 lines (119 loc) · 4.73 KB
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
<?php
require_once 'database.php';
$con=mysqli_connect($db_host, $db_username, $db_password,$db_name);
$survivor_id = $_POST['id'];
if($_POST['type'] == 'HuntXP'){
$hunt = explode(",", $_POST['value']);
if($hunt['0'] == 'less'){
$new_value = $hunt['1'] - 1;
}else{
$new_value = $hunt['1'] + 1;
}
$sql = "UPDATE hunt_xp SET XP ='".$new_value."' WHERE ID_SURVIVOR='".$_POST['id']."'";
if ($con->query($sql) === TRUE) {
error_log('sucess');
} else {
error_log( "Error updating record: " . $con->error);
}
?>
<label class="checkbox">Hunt XP: </label>
<?php
$survivor_id = $_POST['id'];
$hunt_xp = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM hunt_xp WHERE ID_SURVIVOR = $survivor_id"));
for ($i = 1; $i <= $hunt_xp['XP']; $i++) {
echo ' <input type="checkbox" class="test2" value="less,'.$hunt_xp['XP'].'" id="HuntXP" aria-label="..." checked> ';
}
$uncheck_huntXP = 15 - $hunt_xp['XP'];
for ($s = 1; $s <= $uncheck_huntXP; $s++) {
echo ' <input type="checkbox" class="test2" value="more,'.$hunt_xp['XP'].'" id="HuntXP" aria-label="..." > ';
}
}elseif ($_POST['type'] == 'proficiency') {
$proficiency = explode(",", $_POST['value']);
if($proficiency['0'] == 'less'){
$new_value = $proficiency['1'] - 1;
}else{
$new_value = $proficiency['1'] + 1;
}
$sql = "UPDATE w_proficiency SET PROFICIENCY ='".$new_value."' WHERE ID_SURVIVOR='".$_POST['id']."'";
if ($con->query($sql) === TRUE) {
error_log('sucess');
} else {
error_log( "Error updating record: " . $con->error);
}
?>
<label class="checkbox">Weapon proficiency: </label>
<?php
$survivor_id = $_POST['id'];
$w_proficiency = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM w_proficiency WHERE ID_SURVIVOR = $survivor_id"));
for ($i = 1; $i <= $w_proficiency['PROFICIENCY']; $i++) {
echo ' <input type="checkbox" class="test2" value="less,'.$w_proficiency['PROFICIENCY'].'" id="proficiency" aria-label="..." checked> ';
}
$uncheck_proficiency = 15 - $w_proficiency['PROFICIENCY'];
for ($s = 1; $s <= $uncheck_proficiency; $s++) {
echo ' <input type="checkbox" class="test2" value="more,'.$w_proficiency['PROFICIENCY'].'" id="proficiency" aria-label="..." > ';
}
}elseif ($_POST['type'] == 'Courage') {
$courage = explode(",", $_POST['value']);
if($courage['0'] == 'less'){
$new_value = $courage['1'] - 1;
}else{
$new_value = $courage['1'] + 1;
}
$sql = "UPDATE courage SET COURAGE ='".$new_value."' WHERE ID_SURVIVOR='".$_POST['id']."'";
if ($con->query($sql) === TRUE) {
error_log('sucess');
} else {
error_log( "Error updating record: " . $con->error);
}
?>
<label class="checkbox">Courage </label>
<?php
$courage = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM courage WHERE ID_SURVIVOR = $survivor_id"));
for ($i = 1; $i <= $courage['COURAGE']; $i++) {
echo ' <input type="checkbox" class="test2" value="less,'.$courage['COURAGE'].'" id="Courage" aria-label="..." checked> ';
}
$uncheck_courage = 10 - $courage['COURAGE'];
for ($s = 1; $s <= $uncheck_courage; $s++) {
echo ' <input type="checkbox" class="test2" value="more,'.$courage['COURAGE'].'" id="Courage" aria-label="..." > ';
}
} elseif ($_POST['type'] == 'Understanding') {
$understanding = explode(",", $_POST['value']);
if($understanding['0'] == 'less'){
$new_value = $understanding['1'] - 1;
}else{
$new_value = $understanding['1'] + 1;
}
$sql = "UPDATE understanding SET Understanding ='".$new_value."' WHERE ID_SURVIVOR='".$_POST['id']."'";
if ($con->query($sql) === TRUE) {
error_log('sucess');
} else {
error_log( "Error updating record: " . $con->error);
}
?>
<label class="checkbox">Understanding </label>
<?php
$understanding = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM understanding WHERE ID_SURVIVOR = $survivor_id"));
for ($i = 1; $i <= $understanding['Understanding']; $i++) {
echo ' <input type="checkbox" class="test2" value="less,'.$understanding['Understanding'].'" id="Understanding" aria-label="..." checked> ';
}
$uncheck_understanding = 10 - $understanding['Understanding'];
for ($s = 1; $s <= $uncheck_understanding; $s++) {
echo ' <input type="checkbox" class="test2" value="more,'.$understanding['Understanding'].'" id="Understanding" aria-label="..." > ';
}
}
?>
<script>
$('.test2').off().on('click', function() {
var itemVal = $(this).val();
var character = <?php echo $survivor_id; ?>;
var itemID = $(this).attr('id');
$.ajax({
url: "update_exp.php",
type: 'POST',
data: { value: itemVal, id : character, type: itemID} ,
}).success(function(data){
var section = '#update_' + itemID;
$(section).html(data);
});
});
</script>