-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathedit-kriteria.php
105 lines (102 loc) · 3.09 KB
/
edit-kriteria.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
<?php
include "header.php";
include "includes/config.php";
//code edit data
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: missing ID.');
$query = mysqli_query($koneksi,"SELECT * FROM kriteria WHERE id_kriteria='$id'");
$getRow = mysqli_fetch_array($query);
$query2 = mysqli_query($koneksi,"SELECT * FROM kriteria WHERE id_kriteria='$id'");
$getRow2 = mysqli_fetch_array($query2);
$query3 = mysqli_query($koneksi,"SELECT * FROM kriteria WHERE id_kriteria='$id'");
$getRow3 = mysqli_fetch_array($query3);
$readlAllket = mysqli_query($koneksi,"SELECT * FROM nilai_kriteria ORDER BY id_nilai_kriteria ASC");
$readlAllnk = mysqli_query($koneksi,"SELECT * FROM nilai_kriteria ORDER BY id_nilai_kriteria ASC");
//code update data
if ($_POST) {
$nm = $_POST['nm'];
$tp = $_POST['tp'];
$bbt = $_POST['bbt'];
$update = mysqli_query($koneksi,"UPDATE kriteria
SET nama_kriteria='$nm',tipe_kriteria='$tp',bobot_kriteria='$bbt'
WHERE id_kriteria ='$id'");
if ($update) {
echo "<script>location.href='kriteria.php'</script>";
}else {
echo "Gagal";
}
}
?>
<br>
<div class="container">
<div class="row">
<div class="col-md-6 text-left">
<h4>Form Ubah Kriteria</h4>
</div>
<div class="col-md-6">
</div>
</div>
<br><br>
<form method="POST" action="">
<div class="form-group">
<label for="id">Id Kriteria</label>
<div>
<input type="text" class="form-control" id="id" name="id" value="<?php echo $getRow['id_kriteria'] ?>" disabled>
</div>
</div>
<div class="form-group">
<label for="nm">Nama Kriteria</label>
<div>
<select class="form-control" id="nm" name="nm">
<option><?php echo $getRow2['nama_kriteria']; ?></option>
<?php
while ($row = mysqli_fetch_assoc($readlAllket)){
if ($row['ket_nilai_kriteria'] == $getRow2['nama_kriteria']) {
}else{
extract($row);
echo "<option value='{$ket_nilai_kriteria}'>{$ket_nilai_kriteria}</option>";
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="tp">Tipe Kriteria</label>
<div>
<select class="form-control" id="tp" name="tp">
<option><?php echo $getRow['tipe_kriteria']; ?></option>
<?php
if ($getRow['tipe_kriteria'] == "cost") {
echo"<option value='benefit'>Benefit</option>";
}else {
echo "<option value='cost'>Cost</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="bbt">Bobot Kriteria</label>
<div>
<select class="form-control" id="bbt" name="bbt">
<option><?php echo $getRow3['bobot_kriteria']; ?></option>
<?php
while ($row = mysqli_fetch_assoc($readlAllnk)){
if ($row['jum_nilai_kriteria'] == $getRow3['bobot_kriteria']) {
}else{
extract($row);
echo "<option value='{$jum_nilai_kriteria}'>{$jum_nilai_kriteria}</option>";
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary">Ubah</button>
<button type="button" onclick="location.href='kriteria.php'" class="btn btn-success">Kembali</button>
</div>
</div>
</form>
</div>