-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlihat_data.php
123 lines (113 loc) · 5.27 KB
/
lihat_data.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php include 'layout.php'; ?>
<div class="konten">
<div class="col-sm-9">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-tower"></span> Melihat Data DMU</h3>
</div>
<div class="panel-body">
<div class="dataTable_wrapper">
<legend>Daftar Data DMU</legend>
<br><br><br>
<?php
if (isset($_GET['balasan']) and ($_GET['balasan'] == 1)) {
echo '<div class="alert alert-dismissible alert-success"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-ok"></span> Data berhasil ditambahkan</div>';
} elseif (isset($_GET['balasan']) and ($_GET['balasan'] == 2)) {
echo '<div class="alert alert-dismissible alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-exclamation-sign"></span> Kesalahan telah terjadi</div>';
} elseif (isset($_GET['balasan']) and ($_GET['balasan'] == 3)) {
echo '<div class="alert alert-dismissible alert-success"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-ok"></span> Data berhasil dihapus</div>';
} elseif (isset($_GET['balasan']) and ($_GET['balasan'] == 4)) {
echo '<div class="alert alert-dismissible alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-exclamation-sign"></span> Gagal menghapus data</div>';
} elseif (isset($_GET['balasan']) and ($_GET['balasan'] == 5)) {
echo '<div class="alert alert-dismissible alert-success"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-ok"></span> Data berhasil diubah</div>';
} elseif (isset($_GET['balasan']) and ($_GET['balasan'] == 6)) {
echo '<div class="alert alert-dismissible alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><span class="glyphicon glyphicon-exclamation-sign"></span> Gagal mengubah data</div>';
}
// Menghitung jumlah var input dan output
$query = mysqli_query($conn, "SELECT * FROM variabel ORDER BY jenis_variabel ASC, id_variabel ASC");
$list_var = '';
$input = 0;
$output = 0;
if (mysqli_num_rows($query) > 0) {
while ($var = mysqli_fetch_assoc($query)) {
if ($var['jenis_variabel'] == 'i') {
$input++;
} else {
$output++;
}
$nama = str_replace('_', ' ', $var['nama_variabel']);
$list_var .= "<th>$nama</th>";
}
}
# Menampilkan Data Tabel
$i = 1;
$query = mysqli_query($conn, 'SELECT k.cabang_prodi, d.id_prodi FROM prodi AS k, detail_dmu AS d WHERE k.id_prodi=d.id_prodi GROUP BY id_prodi ORDER BY id_detail_dmu');
if (mysqli_num_rows($query) > 0) {
echo '
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th rowspan="2" style="text-align: center;">No</th>
<th rowspan="2" style="text-align: center;">Program Studi</th>
<th colspan="' . $input . '" style="text-align: center;">Input</th>
<th colspan="' . $output . '"style="text-align: center;">Output</th>
</tr>
<tr>
' . $list_var . '
</tr>
</thead>
<tbody>
';
while ($cabang = mysqli_fetch_assoc($query)) {
echo '
<tr>
<td>' . $cabang["id_prodi"] . '</td>
<td>' . $cabang["cabang_prodi"] . '</td>
';
$id_prodi = $cabang['id_prodi'];
// Variabel Input
$query_input = mysqli_query($conn, 'SELECT d.nilai_variabel FROM detail_dmu AS d, variabel AS v WHERE d.id_variabel=v.id_variabel AND id_prodi=' . $id_prodi . ' AND v.jenis_variabel="i" ORDER BY v.jenis_variabel ASC, d.id_variabel');
$count = 0;
if (mysqli_num_rows($query_input)) {
while ($nilai_var = mysqli_fetch_assoc($query_input)) {
echo '<td>' . $nilai_var["nilai_variabel"] . '</td>';
$count++;
}
}
if ($count < $input) {
for ($k = $count; $k < $input; $k++) {
echo '<td></td>';
}
}
// Variabel Output
$query_output = mysqli_query($conn, 'SELECT d.nilai_variabel FROM detail_dmu AS d, variabel AS v WHERE d.id_variabel=v.id_variabel AND id_prodi=' . $id_prodi . ' AND v.jenis_variabel="o" ORDER BY v.jenis_variabel ASC, d.id_variabel');
$count = 0;
if (mysqli_num_rows($query_output)) {
while ($nilai_var = mysqli_fetch_assoc($query_output)) {
echo '<td>' . $nilai_var["nilai_variabel"] . '</td>';
$count++;
}
}
if ($count < $output) {
for ($j = $count; $j < $output; $j++) {
echo '<td></td>';
}
}
echo '
</tr>
';
$i++;
}
$q = mysqli_query($conn, 'SELECT id_prodi FROM detail_dmu GROUP BY id_prodi');
if (mysqli_num_rows($q) == 1) {
} else {
}
} else {
}
?>
</div>
</div>
</div>
</div> <!-- End of Main Content (Second col-sm-9) -->
</div>
<?php include 'layout2.php' ?>