-
Notifications
You must be signed in to change notification settings - Fork 0
/
hasil.php
130 lines (105 loc) · 2.67 KB
/
hasil.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
124
125
126
127
128
129
130
<head>
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
</head>
<?php
include('config.php');
include('fungsi.php');
// menghitung perangkingan
$jmlKriteria = getJumlahKriteria();
$jmlAlternatif = getJumlahAlternatif();
$nilai = array();
// mendapatkan nilai tiap alternatif
for ($x=0; $x <= ($jmlAlternatif-1); $x++) {
// inisialisasi
$nilai[$x] = 0;
for ($y=0; $y <= ($jmlKriteria-1); $y++) {
$id_alternatif = getAlternatifID($x);
$id_kriteria = getKriteriaID($y);
$pv_alternatif = getAlternatifPV($id_alternatif,$id_kriteria);
$pv_kriteria = getKriteriaPV($id_kriteria);
$nilai[$x] += ($pv_alternatif * $pv_kriteria);
}
}
// update nilai ranking
for ($i=0; $i <= ($jmlAlternatif-1); $i++) {
$id_alternatif = getAlternatifID($i);
$query = "INSERT INTO ranking VALUES ($id_alternatif,$nilai[$i]) ON DUPLICATE KEY UPDATE nilai=$nilai[$i]";
$result = mysqli_query($koneksi,$query);
if (!$result) {
echo "Gagal mengupdate ranking";
exit();
}
}
include('navbar.php');
?>
<section class="content container mt-5">
<h2 class="ui header">Hasil Perhitungan</h2>
<table class="ui celled table">
<thead>
<tr>
<th>Overall Composite Height</th>
<th>Priority Vector (rata-rata)</th>
<?php
for ($i=0; $i <= (getJumlahAlternatif()-1); $i++) {
echo "<th>".getAlternatifNama($i)."</th>\n";
}
?>
</tr>
</thead>
<tbody>
<?php
for ($x=0; $x <= (getJumlahKriteria()-1) ; $x++) {
echo "<tr>";
echo "<td>".getKriteriaNama($x)."</td>";
echo "<td>".round(getKriteriaPV(getKriteriaID($x)),5)."</td>";
for ($y=0; $y <= (getJumlahAlternatif()-1); $y++) {
echo "<td>".round(getAlternatifPV(getAlternatifID($y),getKriteriaID($x)),5)."</td>";
}
echo "</tr>";
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="2">Total</th>
<?php
for ($i=0; $i <= ($jmlAlternatif-1); $i++) {
echo "<th>".round($nilai[$i],5)."</th>";
}
?>
</tr>
</tfoot>
</table>
<h2 class="ui header">Perangkingan</h2>
<table class="ui celled blue table">
<thead>
<tr>
<th>Peringkat</th>
<th>Alternatif</th>
<th>Nilai</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT id,nama,id_alternatif,nilai FROM alternatif,ranking WHERE alternatif.id = ranking.id_alternatif ORDER BY nilai DESC";
$result = mysqli_query($koneksi, $query);
$i = 0;
while ($row = mysqli_fetch_array($result)) {
$i++;
?>
<tr>
<?php if ($i == 1) {
echo "<td><div>1</div></td>";
} else {
echo "<td>".$i."</td>";
}
?>
<td><?php echo $row['nama'] ?></td>
<td><?php echo $row['nilai'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</section>