Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "koneksi.php";
- $query ="SELECT s.usia, s.berat_badan, s.tinggi_badan
- FROM status_gizi s, balita b
- WHERE s.balita_no_identitas=b.no_identitas
- AND b.jenis_kelamin='perempuan'
- AND s.balita_no_identitas=1";
- $hasil = mysql_query($query);
- $index=array('usia','berat_badan','tinggi_badan');
- $max=array('usia'=>0,'berat_badan'=>0,'tinggi_badan'=>0);
- $v=array();
- $i=0;
- $n=count($index);
- while ($data = mysql_fetch_array($hasil)){
- for($j=0;$j<$n;$j++){
- $bobot=mt_rand(1,1000)/10000;
- $v[$index[$j]]=$data[$index[$j]]*$bobot;
- echo $data[$index[$j]]." * ".$bobot." = ".$v[$index[$j]]."<br>\n";
- $max[$index[$j]]=($max[$index[$j]]<$v[$index[$j]]?$v[$index[$j]]:$max[$index[$j]]);
- }
- $i++;
- }
- for($i=0;$i<$n;$i++){
- echo "max ".ucwords(str_replace("_"," ",$index[$i]))." = ".$max[$index[$i]]."<br>\n";
- }
- ?>
- ===
- <?php
- include "koneksi.php";
- $query ="SELECT s.usia, s.berat_badan, s.tinggi_badan
- FROM status_gizi s, balita b
- WHERE s.balita_no_identitas=b.no_identitas
- AND b.jenis_kelamin='perempuan'
- AND s.balita_no_identitas=1";
- $hasil = mysql_query($query);
- $index=array('usia','berat_badan','tinggi_badan');
- $max=array('usia'=>0,'berat_badan'=>0,'tinggi_badan'=>0);
- $v=array();
- $total=array();
- $i=0;
- $n=count($index);
- while ($data = mysql_fetch_array($hasil)){
- for($j=0;$j<$n;$j++){
- $bobot=mt_rand(1,1000)/10000;
- $v[$index[$j]]=$data[$index[$j]]*$bobot;
- $total[$index[$j]]+=$data[$index[$j]];
- $max[$index[$j]]=($max[$index[$j]]<$v[$index[$j]]?$v[$index[$j]]:$max[$index[$j]]);
- }
- $i++;
- }
- for($i=0;$i<$n;$i++){
- echo "max ".ucwords(str_replace("_"," ",$index[$i]))." = ".($max[$index[$i]]/$total[$index[$i]])."<br>\n";
- }
- ?>
- ===
- <?php
- include "koneksi.php";
- $query ="SELECT s.usia, s.berat_badan, s.tinggi_badan
- FROM status_gizi s, balita b
- WHERE s.balita_no_identitas=b.no_identitas
- AND b.jenis_kelamin='perempuan'
- AND s.balita_no_identitas=1";
- $hasil = mysql_query($query);
- $value_title=array('usia','berat_badan','tinggi_badan');
- $value=array();
- $total=array(0,0,0);
- $i=0;
- $n=count($value_title);
- while ($data = mysql_fetch_array($hasil)){
- $value[$i]=array();
- for($j=0;$j<$n;$j++){
- $value[$i][$j]=$data[$j];
- $total[$j]+=$data[$j];
- }
- $i++;
- }
- //------------
- $jumlah_data=$i-1;
- $bobot=array();
- $value_bobot=array();
- $max=array(0,0,0);
- for($i=0;$i<$jumlah_data;$i++){
- $bobot[$i]=array();
- $value_bobot[$i]=array();
- for($j=0;$j<$n;$j++){
- $bobot[$i][$j]=(mt_rand(1,1000)/10000)/$total[$j];
- $value_bobot[$i][$j]=$value[$i][$j]*$bobot[$i][$j];
- $max[$j]=$max[$j]<$value_bobot[$i][$j]?$value_bobot[$i][$j]:$max[$j];
- echo $value[$i][$j]." * ".$bobot[$i][$j]." = ".$value_bobot[$j]."<br>\n";
- }
- }
- //------------
- $value_title=array('usia','berat_badan','tinggi_badan');
- for($i=0;$i<$n;$i++){
- echo "max ".ucwords(str_replace("_"," ",$value_title[$i]))
- ." = ".$max[$i]."<br>\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement