Skip to content

Instantly share code, notes, and snippets.

@adibenc
Last active August 24, 2019 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adibenc/d7f8c06e3485b0e83b1a64274f337f88 to your computer and use it in GitHub Desktop.
Save adibenc/d7f8c06e3485b0e83b1a64274f337f88 to your computer and use it in GitHub Desktop.
4 devi
<?php
require_once('koneksi.php');
$sql = mysqli_query($conn, "SELECT id_data, tempat_wisata, dcuaca, djumlah_pengunjung, dspot_wisata, dtiket_wisata, dfasilitas_umum
FROM data, alternatif where data.id_alt=alternatif.id_alternatif");
//Pembagi
while ($data1= mysqli_fetch_array($sql)){
$c[] = pow($data1['dcuaca'],2);
$j[] = pow($data1['djumlah_pengunjung'],2);
$s[] = pow($data1['dspot_wisata'],2);
$t[] = pow($data1['dtiket_wisata'],2);
$f[] = pow($data1['dfasilitas_umum'],2);
}
//Total
$Pc = round(sqrt(array_sum($c)),4);
$Pj = round(sqrt(array_sum($j)),4);
$Ps= round(sqrt(array_sum($s)),4);
$Pt= round(sqrt(array_sum($t)),4);
$Pf= round(sqrt(array_sum($f)),4);
//Tampilkan
echo "<br/>Pembagi :<br/>";
echo "$Pc<br/>";
echo "$Pj<br/>";
echo "$Ps<br/>";
echo "$Pt<br/>";
echo "$Pf<br/><br/><br/>";
//Normalisasi
$sql2 = mysqli_query($conn, "SELECT id_data, dcuaca, djumlah_pengunjung, dspot_wisata, dtiket_wisata, dfasilitas_umum FROM data");
echo '<table width = 800 border =1>
<caption>NORMALISASI</caption>
<thead>
<tr bgcolor=00fffff>
<th>ID DATA</th>
<th>CUACA</th>
<th>JUMLAH PENGUNJUNG</th>
<th>SPOT WISATA</th>
<th>TIKET WISATA</th>
<th>FASILITAS UMUM</th>
</tr>
</thead>
<tbody>';
while ($data2 = mysqli_fetch_array($sql2)){
$dc = round(($data2['dcuaca'] / $Pc),4);
$dj = round(($data2['djumlah_pengunjung'] / $Pj),4);
$ds = round(($data2['dspot_wisata'] / $Ps),4);
$dt = round(($data2['dtiket_wisata'] / $Pt),4);
$df = round(($data2['dfasilitas_umum'] / $Pf),4);
echo '<tr>
<td align="center">'.$data2['id_data'].'</td>
<td align="center">'.$dc.'</td>
<td align="center">'.$dj.'</td>
<td align="center">'.$ds.'</td>
<td align="center">'.$dt.'</td>
<td align="center">'.$df.'</td>
</tr>';
}
//Normalisasi Terbobot
//include 'login.php';
$sql = mysqli_query($conn, "SELECT id_data, dcuaca, djumlah_pengunjung, dspot_wisata, dtiket_wisata, dfasilitas_umum FROM data");
$bobot = mysqli_query($conn, "SELECT id_bobot, id_user, cuaca, jumlah_pengunjung, spot_wisata, tiket_masuk, fasilitas_umum
FROM bobot, user WHERE bobot.id_userb=user.id_user");
//$user = mysqli_query($conn, "SELECT * FROM user WHERE username = '".$log_username."' ");
echo '<table width = 800 border =1>
<caption>NORMALISASI TERBOBOT</caption>
<thead>
<tr bgcolor=00fffff>
<th>ID DATA</th>
<th>CUACA</th>
<th>JUMLAH PENGUNJUNG</th>
<th>SPOT WISATA</th>
<th>TIKET WISATA</th>
<th>FASILITAS UMUM</th>
</tr>
</thead>
<tbody>';
//if($bobot == $user){
$row = mysqli_fetch_array($bobot);
//dari adib
$dataakhir=[
"cuaca"=>[],
"jml"=>[],
"spot"=>[],
"tiket"=>[],
"fasilitas"=>[],
];
$q=0;
//echo sizeof($data3);
//exit();
while ($data3 = mysqli_fetch_array($sql)){
$bc = round(($data3['dcuaca'] / $Pc),4) * $row['cuaca'] ;
$bj = round(($data3['djumlah_pengunjung'] / $Pj),4) * $row['jumlah_pengunjung'];
$bs = round(($data3['dspot_wisata'] / $Ps),4) * $row['spot_wisata'];
$bt = round(($data3['dtiket_wisata'] / $Pt),4) * $row['tiket_masuk'];
$bf = round(($data3['dfasilitas_umum'] / $Pf),4) * $row['fasilitas_umum'];
echo '<tr>
<td align="center">'.$data3['id_data'].'</td>
<td align="center">'.$bc.'</td>
<td align="center">'.$bj.'</td>
<td align="center">'.$bs.'</td>
<td align="center">'.$bt.'</td>
<td align="center">'.$bf.'</td>
</tr>';
//adib
$dataakhir["cuaca"][]=$bc;
$dataakhir["jml"][]=$bj;
$dataakhir["spot"][]=$bs;
$dataakhir["tiket"][]=$bt;
$dataakhir["fasilitas"][]=$bf;
$q++;
}
?>
</tbody>
</table>
<?php
// var_dump($avg_data);
// exit();
//echo sizeof($data3);
//}
//Solusi Ideal
echo '<table width = 800 border =1>
<caption>SOLUSI IDEAL</caption>
<thead>
<tr bgcolor=00fffff>
<th>SOLUSI IDEAL</th>
<th>CUACA</th>
<th>JUMLAH PENGUNJUNG</th>
<th>SPOT WISATA</th>
<th>TIKET WISATA</th>
<th>FASILITAS UMUM</th>
</tr>
</thead>
<tbody>';
//A+
//$scp = min (array($bc));
//$sjp = max (array($bj));
//$ssp = max (array($bs));
//$stp = min (array($bt));
//$sfp = max (array($bf));
//dib
$scp = min ($dataakhir["cuaca"]);
$sjp = max ($dataakhir["jml"]);
$ssp = max ($dataakhir["spot"]);
$stp = min ($dataakhir["tiket"]);
$sfp = max ($dataakhir["fasilitas"]);
echo '<tr>
<td align="center">A+</td>
<td align="center">'.$scp.'</td>
<td align="center">'.$sjp.'</td>
<td align="center">'.$ssp.'</td>
<td align="center">'.$stp.'</td>
<td align="center">'.$sfp.'</td>
</tr>';
//A-
// $scn = max (array($bc));
// $sjn = min (array($bj));
// $ssn = min (array($bs));
// $stn = max (array($bt));
// $sfn = min (array($bf));
//dib
$scn = max ($dataakhir["cuaca"]);
$sjn = min ($dataakhir["jml"]);
$ssn = min ($dataakhir["spot"]);
$stn = max ($dataakhir["tiket"]);
$sfn = min ($dataakhir["fasilitas"]);
echo '<tr>
<td align="center">A-</td>
<td align="center">'.$scn.'</td>
<td align="center">'.$sjn.'</td>
<td align="center">'.$ssn.'</td>
<td align="center">'.$stn.'</td>
<td align="center">'.$sfn.'</td>
</tr>';
?>
</tbody>
</table>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment