Rimbawan nyoba coding PHP [ya berantakan..!!]

seminggu belakangan nyoba coding buat bikin aplikasi penghitung Index Nilai Penting a.k.a INP, dan temen-temennya.. ya sebut saja namanya kalkulator INP. dan karena saia menjunjung tinggi kebebasan informasi dan ilmu pengetahuan aplikasi ini saia share saja siapa tahu ada yang butuh,, terutama buat ade2 tingkat FAHUTAN yang malles ngitung di M.K Ekologi Hutan .

sebenernya aplikasi ini blum selese 100% karena untuk perhitungan semai dan herba belum di sertakan, studi contoh disini menggunakan perhitungan untuk jenis pohon,tapi kalo mau make, coba baca2 baca dulu kode yang berantakan itu niscaya bisa di kondisikan untuk herba, pancang dan semai penggunaan data basenya: field data base terdiri dari 5[sebenernya] tapi gara2 suatu hal jadi 15 field hehe..[nanti
.

pada dasarnya aplikasi ini bisa berjalan di komputer kelas apapun dengan sistem operasi apapun, karena bahasa yang digunakan adalah PHP, yang perlu disesuaikan adalah mengenai peng coba saia perbaiki].

mudah-mudahan dalam waktu dekat sudah dapat dinikmati bagi yang pengen menikmati.. bagi yang ngerti PHP kalo sempat liat ni code tolong di koreksi.[saya merasa kode-kode yang saya pakai ga efektif] tapi apabole buat namanya juga belajar.

ini kodenya :

<html>
<head>
<title></title>
</head>
<body>
<p align=”center”><span style=”text-transform: uppercase”>Prototype Perhitungan Ngaco</span></p>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”table1″>
<tr bgcolor=#ccccff>
<th>Pu</th>
<th>Jenis</th>
<th>Keliling (cm)</th>
<th>Tinggi Total (m)</th>
<th>TBC (m)</th>
<th>lbds (m/ha)</th>
<th>diameter (m)</th>
<th>volume (m3)</th>
</tr>

<?php
error_reporting(E_ALL);
//konak ke database
$con=mysql_connect(“localhost”,”root”,””);
if($con){
echo “konak”;
}else{
echo “ga konak”;}
//========================================
//proses inisialisasi
//========================================
//pilih database
mysql_select_db(“test1”);

//ambil data dari tabel uji
$data=mysql_query(“select * from uji order by jenis”);
$data2=mysql_query(“select jenis,sum(tbc) from uji order by jenis”);
$data3=mysql_query(“select pu from uji group by pu”);
$data4=mysql_query(“select jenis,pu,count(jenis),count(distinct jenis) from uji group by jenis,pu order by jenis,pu asc”);
/*untuk inisialisasi luas petak dimasukkan kemudian*/

$jen=array(); //inisialisasi array individu
$kel=array();
$dia=array(); //inisialisasi array diameter
$vol=array(); //inisialisasi array volume
$tt=array();
$tb=array();
$lbd=array();
$rpt=array(); //inisialisasi array kerapatan
$dom=array(); //inisialisasi array dominansi
$frq=array(); //inisialisasi array frekuensi
$con=array(); //inisialisasi jumlah masing2 individu
$sp=array(); //inisialisasi jumlah spesies
$pu=array(); //inisialisasi jumlah petak ukur
$kr=array(); //inisialisasi kerapatan relatif
$fr=array(); //inisialisasi frek relatif
$dr=array(); //inisialisasi dom relatif
$ujen=array(); //inisialisasi array jenis yang di urutkan
$jj2=array(); //untuk jumlah species
$kd1=array(); //pengkelasan jml diameter
$kd2=array();
$kd3=array();
$kd4=array();

//pemasukan data ke array pertama
while($test=mysql_fetch_array($data))
{
//proses inisialisasi nilai dari mysql ke array
array_push($pu,$test[13]);
array_push($jen,$test[0]);
array_push($tt,$test[1]);
array_push($tb,$test[2]);
array_push($kel,$test[3]);
}

//hitung jumlah pu
$jpu=count($jen);
//hitung jumlah jenis
$urut=array_unique($jen);

//===========================================
//————Eof—————————-
//============================================
for($n=0;$n<$jpu;$n++){
//diameter
$a[$n]=$kel[$n]/M_PI;
array_push($dia,$a[$n]);

//lbds
$b[$n]=M_PI_4*$a[$n]*$a[$n];
array_push($lbd,$b[$n]);

//volume
$c[$n]=0.7*$b[$n]*$tb[$n];
array_push($vol,$c[$n]);
}

//========================================================
//mulai kerja!!
//=======================================================
for($i=0;$i<=$jpu;$i++) {

//masukkan hasil kerapatan dalam sebuah file
//buat arai dari file
//jumlahkan file arai

echo”<tr bgcolor=#”.($i%2? “f0f0f0″:”cccccc”).”>
<td align=center>$pu[$i]</td>
<td align=center>$jen[$i]</td> <!–jenis–>
<td align=center>$kel[$i]</td> <!–keliling–>
<td align=center>$tt[$i]</td> <!–tinggi total–>
<td align=center>$tb[$i]</td> <!–tinggi bebas cabang–>
<td align=left>$lbd[$i]</td> <!–LBDS–>
<td align=left>$dia[$i]</td> <!–volume total tiap jenis–>
<td align=left>$vol[$i]</td> <!–kerapatan–>
</tr>”;}

?>

</table>
<br><br>
<center>~~LANJUTAN PERHITUNGAN NGACO~~</center>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=table2 >
<tr bgcolor=#ccccff>
<th>jenis</th>
<th>lbds total jenis</th>
<th>volume total jenis </th>
<th>K</th>
<th>Kr</th>
<th>F</th>
<th>Fr</th>
<th>D</th>
<th>Dr</th>
<th>INP</th>
</tr>

<?php
$cuj=array_values($urut);
$ujen=count($urut);
//mapping lbds total tiap jenis
$map1=array_map(null,$jen,$lbd);
$slbd=array(); //jumlah lbds tiap jenis
$jpj=array(); //jumlah per jenis
for($i=0;$i<$ujen;$i++){
$su=array();
for($j=0;$j<=$jpu;$j++){
$in1=in_array($cuj[$i],$map1[$j]);
if($in1){
array_push($su,$map1[$j][1]);}}
$sum1=array_sum($su);
$hit=count($su);
array_push($jpj,$hit);
array_push($slbd,$sum1);
}
//==eof==
//print_r($jpj);//geDebuogg
//mapping volume total tiap jenis
$map2=array_map(null,$jen,$vol);
$svol=array();
$vjpj=array();
for($i=0;$i<$ujen;$i++){
$sv=array();
for($j=0;$j<=$jpu;$j++){
$in2=in_array($cuj[$i],$map2[$j]);
if($in2){
array_push($sv,$map2[$j][1]);}}
$sum2=array_sum($sv);
array_push($svol,$sum2);
}
//==eof===

//kerapatan
for($i=0;$i<$ujen;$i++){
$rapat=$jpj[$i]/0.2;
array_push($rpt,$rapat);}
$srpt=array_sum($rpt);
//===eof==

//kerapatan relatif
for($i=0;$i<$ujen;$i++){
$rrel=$rpt[$i]/$srpt;
array_push($kr,$rrel);
}
//===eof===

//frekuensi
//hitung jumlah pu
$bus=array();
$kur=mysql_query(“select pu from uji group by pu”);
while($bon=mysql_fetch_array($kur)){
array_push($bus,$bon[0]);
}
$em=count($bus);
$om=count($jen);
print_r($em);
//hitung frekuensi
$jon=array_count_values($jen);
$pol=array(); //inisialisasi data frekuensi
while(list($key,$val)=each($jon)){
array_push($pol,$val);
}
$sfre=array_sum($pol);

//frekuensi relatif
for($i=0;$i<$ujen;$i++){
$frel=$pol[$i]/$sfre;
array_push($fr,$frel);
}
//dominansi
for($i=0;$i<$ujen;$i++){
$domin=$slbd[$i]/0.2; //0.2 adalah luas petak ukur
array_push($dom,$domin);
}
$sdom=array_sum($dom);
//===eof=====

//dominansi relatif
for($i=0;$i<$ujen;$i++){
$domre=$dom[$i]/$sdom;
array_push($dr,$domre);
}
//====eof===

//inp
$inp=array();
for($i=0;$i<$ujen;$i++){
$inx=$kr[$i]+$fr[$i]+$dr[$i];
array_push($inp,$inx);
}
//=====eof===

for($m=0;$m<$ujen;$m++){
echo”<tr bgcolor=#”.($m % 2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$m]</td>
<td align=left>$slbd[$m]</td>
<td align=left>$svol[$m]</td>
<td align=left>$rpt[$m]</td> <!–0.2 luas pu–>

<td align=left>$kr[$m]</td>
<td aling=left>$pol[$m]</td>
<td align=left>$fr[$m]</td>
<td align=left>$dom[$m]</td>
<td align=left>$dr[$m]</td>
<td align=left>$inp[$m]</td>
</tr>”;}

?>

</table>
<br><br>
<center>~~KOLONISASI NGACO~~</center>
<br>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”tabel3″>
<tr bgcolor=#ccccff>
<th rowspan=2>jenis</th>
<th colspan=2>20-29</th>
<th colspan=2>30-39</th>
<th colspan=2>40-49</th>
<th colspan=2>50 up</th>
</tr>
<tr bgcolor=#ccccff>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
</tr>

<?php

//===========================
// perhitungan kolonisasi
//===========================
//diameter
//=============================
function asik($x,$y){
return array($x=>$y);
}

$kelo1=array();
$kelo2=array();
$kelo3=array();
$kelo4=array();
$map4=array_map(‘asik’,$jen,$dia);
//print_r($kelo4);
foreach($map4 as $ci){
foreach($ci as $kaka=>$ganteng){
if($ganteng>0&&0.5>$ganteng){
array_push($kelo1,$kaka);}
if($ganteng>0.51&&1>$ganteng){
array_push($kelo2,$kaka);}
if($ganteng>1.1&&1.5>$ganteng){
array_push($kelo3,$kaka);}
if($ganteng>1.51){
array_push($kelo4,$kaka);}
}}

$qd1=array_count_values($kelo1);
$qd2=array_count_values($kelo2);
$qd3=array_count_values($kelo3);
$qd4=array_count_values($kelo4);

//print_r($kelo1);
echo “<br>”;

$kd1=count();
$kd2=count();
$kd3=count();
$kd4=count();

$ar1=array();
$ar2=array();
$ar3=array();
$ar4=array();

for($i=0;$i<$ujen;$i++){
// echo “<br>”;
array_push($ar1,$qd1[$cuj[$i]]);
array_push($ar2,$qd2[$cuj[$i]]);
array_push($ar3,$qd3[$cuj[$i]]);
array_push($ar4,$qd4[$cuj[$i]]);
}

//print_r($ar1);
//================================
//volume
//=================================

$kelop1=array();
$kelop2=array();
$kelop3=array();
$kelop4=array();
$map6=array_map(null,$jen,$vol,$dia);
//print_r($kelo4);
for($i=0;$i<$jpu;$i++){
if($map6[$i][2]>0&&0.5>$map6[$i][2]){
array_push($kelop1,$map6[$i][1]);}
if($map6[$i][2]>0.51&&1>$map6[$i][2]){
array_push($kelop2,$map6[$i][1]);}
if($map6[$i][2]>1.1&&1.5>$map6[$i][2]){
array_push($kelop3,$map6[$i][1]);}
if($map6[$i][2]>1.51){
array_push($kelop4,$map6[$i][1]);}
}

$qv1=array_map(null,$kelo1,$kelop1);
$qv2=array_map(null,$kelo2,$kelop2);
$qv3=array_map(null,$kelo3,$kelop3);
$qv4=array_map(null,$kelo4,$kelop4);

$kv1=array();
$kv2=array();
$kv3=array();
$kv4=array();

$av1=array();
$av2=array();
$av3=array();
$av4=array();

for($i=0;$i<$ujen;$i++){
$kv1[$qv1[$i][0]][]=$qv1[$i][1];
$kv2[$qv2[$i][0]][]=$qv2[$i][1];
$kv3[$qv3[$i][0]][]=$qv3[$i][1];
$kv4[$qv4[$i][0]][]=$qv4[$i][1];
}
//print_r($kv1);
for($j=0;$j<$ujen;$j++){
$bv1[$j]=array_sum($kv1[$cuj[$j]]);
$bv2[$j]=array_sum($kv2[$cuj[$j]]);
$bv3[$j]=array_sum($kv3[$cuj[$j]]);
$bv4[$j]=array_sum($kv4[$cuj[$j]]);
array_push($av1,$bv1[$j]);
array_push($av2,$bv2[$j]);
array_push($av3,$bv3[$j]);
array_push($av4,$bv4[$j]);
}

//=====================================
//print_r($av1);
//=======================
//tabel saji kolonisasi
//========================
for($p=0;$p<$ujen;$p++){
echo”<tr bgcolor=#”.($p%2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$p]</td>
<td align=center>$ar1[$p]</td>
<td>$av1[$p]</td>
<td align=center>$ar2[$p]</td>
<td>$av2[$p]</d>
<td align=center>$ar3[$p]</td>
<td>$av3[$p]</td>
<td align=center>$ar4[$p]</td>
<td>$av4[$p]</td>
</tr>”;
}
?>
</table>
<br><br>
<center>~~~~INDEKS-INDEKSAN NGACO~~~~~</certer>
<br><br>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”tabel4″>
<tr bgcolor=”#ccccff”>
<th>nama jenis</th>
<th>Jumlah Ind</th>
<th>ni/N</th>
<th>ln(ni/N)</th>
<th>D</th>
<!– <th>R1</th>
<th>E1</th> –>
<th>H</th>
</tr>

<?php
//=======================================
//========Perhitungan Index Dsb==========
//======================================
/*
$len=M_LN10*12;
for($j=0;$j<$ujen;J++){
print_r($jon[$cuj[$j]]);}
*/
$nop=array_values($jon);
//print_r($nop);
//===perhitungan ni/n==========
$as=array_sum($nop);
$np=array();
for($j=0;$j<$ujen;$j++){
$npn[$j]=$nop[$j]/$as;
$np[]=$npn[$j];
}
//print_r($np);
//perhitungan=======ln ni/n======
$lon=array();
for($i=0;$i<$ujen;$i++){
$ln[$i]=log($np[$i]);
$lon[]=$ln[$i];
}

//$cob=log(0.0120481927710843);
//print_r($cob);
//===================dominasi jenis=======
$doj=array();
for($j=0;$j<$ujen;$j++){
$dj[$j]=$np[$j]*$np[$j];
$doj[]=$dj[$j];
}
//=========H aksen======================
$hak=array();
for($i=0;$i<$ujen;$i++){
$hk[$i]=(-1)*$np[$i]*$lon[$i];
$hak[]=$hk[$i];
}
//========nilai H==============
$H=array_sum($hak);

//========nilai R1===============
$R1=($ujen-1)/log($as);

//==========nilai E1============
$E1=$H/log($ujen);

//==========nilai D1===============
$D1=array_sum($doj);

//print_r($hak);
//=======================================
//=========Tabel Saji===================
//=======================================
for($i=0;$i<$ujen;$i++){
echo”<tr bgcolor=#”.($i%2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$i]</td>
<td align=center>$nop[$i]</td>
<td align=center>$np[$i]</td>
<td align=center>$lon[$i]</td>
<td align=center>$doj[$i]</td>
<td align=center>$hak[$i]</td>
</tr>”;
}
echo” </table><br><br>”;
echo”<table border=\”1\” width=\”80%\” cellspacing=\”1\” cellpadding=\”0\”>
<tr bgcolor=#ccccff>
<th>Index keanekaragaman Shannon-Wiener</th>
<th>Index Kekayaan Margalef</th>
<th>index kemerataan</th>
<th>Dominasi</th>
<tr>
<tr bgcolor=#cccccc>
<th>$H</th>
<th>$R1</th>
<th>$E1</th>
<th>$D1</th>
</tr>
“;

?>
</table>

</body>
</html><html>
<head>
<title></title>
</head>
<body>
<p align=”center”><span style=”text-transform: uppercase”>Prototype Perhitungan Ngaco</span></p>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”table1″>
<tr bgcolor=#ccccff>
<th>Pu</th>
<th>Jenis</th>
<th>Keliling (cm)</th>
<th>Tinggi Total (m)</th>
<th>TBC (m)</th>
<th>lbds (m/ha)</th>
<th>diameter (m)</th>
<th>volume (m3)</th>
</tr>

<?php
error_reporting(E_ALL);
//konak ke database
$con=mysql_connect(“localhost”,”root”,””);
if($con){
echo “konak”;
}else{
echo “ga konak”;}
//========================================
//proses inisialisasi
//========================================
//pilih database
mysql_select_db(“test1”);

//ambil data dari tabel uji
$data=mysql_query(“select * from uji order by jenis”);
$data2=mysql_query(“select jenis,sum(tbc) from uji order by jenis”);
$data3=mysql_query(“select pu from uji group by pu”);
$data4=mysql_query(“select jenis,pu,count(jenis),count(distinct jenis) from uji group by jenis,pu order by jenis,pu asc”);
/*untuk inisialisasi luas petak dimasukkan kemudian*/

$jen=array(); //inisialisasi array individu
$kel=array();
$dia=array(); //inisialisasi array diameter
$vol=array(); //inisialisasi array volume
$tt=array();
$tb=array();
$lbd=array();
$rpt=array(); //inisialisasi array kerapatan
$dom=array(); //inisialisasi array dominansi
$frq=array(); //inisialisasi array frekuensi
$con=array(); //inisialisasi jumlah masing2 individu
$sp=array(); //inisialisasi jumlah spesies
$pu=array(); //inisialisasi jumlah petak ukur
$kr=array(); //inisialisasi kerapatan relatif
$fr=array(); //inisialisasi frek relatif
$dr=array(); //inisialisasi dom relatif
$ujen=array(); //inisialisasi array jenis yang di urutkan
$jj2=array(); //untuk jumlah species
$kd1=array(); //pengkelasan jml diameter
$kd2=array();
$kd3=array();
$kd4=array();

//pemasukan data ke array pertama
while($test=mysql_fetch_array($data))
{
//proses inisialisasi nilai dari mysql ke array
array_push($pu,$test[13]);
array_push($jen,$test[0]);
array_push($tt,$test[1]);
array_push($tb,$test[2]);
array_push($kel,$test[3]);
}

//hitung jumlah pu
$jpu=count($jen);
//hitung jumlah jenis
$urut=array_unique($jen);

//===========================================
//————Eof—————————-
//============================================
for($n=0;$n<$jpu;$n++){
//diameter
$a[$n]=$kel[$n]/M_PI;
array_push($dia,$a[$n]);

//lbds
$b[$n]=M_PI_4*$a[$n]*$a[$n];
array_push($lbd,$b[$n]);

//volume
$c[$n]=0.7*$b[$n]*$tb[$n];
array_push($vol,$c[$n]);
}

//========================================================
//mulai kerja!!
//=======================================================
for($i=0;$i<=$jpu;$i++) {

//masukkan hasil kerapatan dalam sebuah file
//buat arai dari file
//jumlahkan file arai

echo”<tr bgcolor=#”.($i%2? “f0f0f0″:”cccccc”).”>
<td align=center>$pu[$i]</td>
<td align=center>$jen[$i]</td> <!–jenis–>
<td align=center>$kel[$i]</td> <!–keliling–>
<td align=center>$tt[$i]</td> <!–tinggi total–>
<td align=center>$tb[$i]</td> <!–tinggi bebas cabang–>
<td align=left>$lbd[$i]</td> <!–LBDS–>
<td align=left>$dia[$i]</td> <!–volume total tiap jenis–>
<td align=left>$vol[$i]</td> <!–kerapatan–>
</tr>”;}

?>

</table>
<br><br>
<center>~~LANJUTAN PERHITUNGAN NGACO~~</center>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=table2 >
<tr bgcolor=#ccccff>
<th>jenis</th>
<th>lbds total jenis</th>
<th>volume total jenis </th>
<th>K</th>
<th>Kr</th>
<th>F</th>
<th>Fr</th>
<th>D</th>
<th>Dr</th>
<th>INP</th>
</tr>

<?php
$cuj=array_values($urut);
$ujen=count($urut);
//mapping lbds total tiap jenis
$map1=array_map(null,$jen,$lbd);
$slbd=array(); //jumlah lbds tiap jenis
$jpj=array(); //jumlah per jenis
for($i=0;$i<$ujen;$i++){
$su=array();
for($j=0;$j<=$jpu;$j++){
$in1=in_array($cuj[$i],$map1[$j]);
if($in1){
array_push($su,$map1[$j][1]);}}
$sum1=array_sum($su);
$hit=count($su);
array_push($jpj,$hit);
array_push($slbd,$sum1);
}
//==eof==
//print_r($jpj);//geDebuogg
//mapping volume total tiap jenis
$map2=array_map(null,$jen,$vol);
$svol=array();
$vjpj=array();
for($i=0;$i<$ujen;$i++){
$sv=array();
for($j=0;$j<=$jpu;$j++){
$in2=in_array($cuj[$i],$map2[$j]);
if($in2){
array_push($sv,$map2[$j][1]);}}
$sum2=array_sum($sv);
array_push($svol,$sum2);
}
//==eof===

//kerapatan
for($i=0;$i<$ujen;$i++){
$rapat=$jpj[$i]/0.2;
array_push($rpt,$rapat);}
$srpt=array_sum($rpt);
//===eof==

//kerapatan relatif
for($i=0;$i<$ujen;$i++){
$rrel=$rpt[$i]/$srpt;
array_push($kr,$rrel);
}
//===eof===

//frekuensi
//hitung jumlah pu
$bus=array();
$kur=mysql_query(“select pu from uji group by pu”);
while($bon=mysql_fetch_array($kur)){
array_push($bus,$bon[0]);
}
$em=count($bus);
$om=count($jen);
print_r($em);
//hitung frekuensi
$jon=array_count_values($jen);
$pol=array(); //inisialisasi data frekuensi
while(list($key,$val)=each($jon)){
array_push($pol,$val);
}
$sfre=array_sum($pol);

//frekuensi relatif
for($i=0;$i<$ujen;$i++){
$frel=$pol[$i]/$sfre;
array_push($fr,$frel);
}
//dominansi
for($i=0;$i<$ujen;$i++){
$domin=$slbd[$i]/0.2; //0.2 adalah luas petak ukur
array_push($dom,$domin);
}
$sdom=array_sum($dom);
//===eof=====

//dominansi relatif
for($i=0;$i<$ujen;$i++){
$domre=$dom[$i]/$sdom;
array_push($dr,$domre);
}
//====eof===

//inp
$inp=array();
for($i=0;$i<$ujen;$i++){
$inx=$kr[$i]+$fr[$i]+$dr[$i];
array_push($inp,$inx);
}
//=====eof===

for($m=0;$m<$ujen;$m++){
echo”<tr bgcolor=#”.($m % 2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$m]</td>
<td align=left>$slbd[$m]</td>
<td align=left>$svol[$m]</td>
<td align=left>$rpt[$m]</td> <!–0.2 luas pu–>

<td align=left>$kr[$m]</td>
<td aling=left>$pol[$m]</td>
<td align=left>$fr[$m]</td>
<td align=left>$dom[$m]</td>
<td align=left>$dr[$m]</td>
<td align=left>$inp[$m]</td>
</tr>”;}

?>

</table>
<br><br>
<center>~~KOLONISASI NGACO~~</center>
<br>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”tabel3″>
<tr bgcolor=#ccccff>
<th rowspan=2>jenis</th>
<th colspan=2>20-29</th>
<th colspan=2>30-39</th>
<th colspan=2>40-49</th>
<th colspan=2>50 up</th>
</tr>
<tr bgcolor=#ccccff>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
<th>n</th>
<th>volume</th>
</tr>

<?php

//===========================
// perhitungan kolonisasi
//===========================
//diameter
//=============================
function asik($x,$y){
return array($x=>$y);
}

$kelo1=array();
$kelo2=array();
$kelo3=array();
$kelo4=array();
$map4=array_map(‘asik’,$jen,$dia);
//print_r($kelo4);
foreach($map4 as $ci){
foreach($ci as $kaka=>$ganteng){
if($ganteng>0&&0.5>$ganteng){
array_push($kelo1,$kaka);}
if($ganteng>0.51&&1>$ganteng){
array_push($kelo2,$kaka);}
if($ganteng>1.1&&1.5>$ganteng){
array_push($kelo3,$kaka);}
if($ganteng>1.51){
array_push($kelo4,$kaka);}
}}

$qd1=array_count_values($kelo1);
$qd2=array_count_values($kelo2);
$qd3=array_count_values($kelo3);
$qd4=array_count_values($kelo4);

//print_r($kelo1);
echo “<br>”;

$kd1=count();
$kd2=count();
$kd3=count();
$kd4=count();

$ar1=array();
$ar2=array();
$ar3=array();
$ar4=array();

for($i=0;$i<$ujen;$i++){
// echo “<br>”;
array_push($ar1,$qd1[$cuj[$i]]);
array_push($ar2,$qd2[$cuj[$i]]);
array_push($ar3,$qd3[$cuj[$i]]);
array_push($ar4,$qd4[$cuj[$i]]);
}

//print_r($ar1);
//================================
//volume
//=================================

$kelop1=array();
$kelop2=array();
$kelop3=array();
$kelop4=array();
$map6=array_map(null,$jen,$vol,$dia);
//print_r($kelo4);
for($i=0;$i<$jpu;$i++){
if($map6[$i][2]>0&&0.5>$map6[$i][2]){
array_push($kelop1,$map6[$i][1]);}
if($map6[$i][2]>0.51&&1>$map6[$i][2]){
array_push($kelop2,$map6[$i][1]);}
if($map6[$i][2]>1.1&&1.5>$map6[$i][2]){
array_push($kelop3,$map6[$i][1]);}
if($map6[$i][2]>1.51){
array_push($kelop4,$map6[$i][1]);}
}

$qv1=array_map(null,$kelo1,$kelop1);
$qv2=array_map(null,$kelo2,$kelop2);
$qv3=array_map(null,$kelo3,$kelop3);
$qv4=array_map(null,$kelo4,$kelop4);

$kv1=array();
$kv2=array();
$kv3=array();
$kv4=array();

$av1=array();
$av2=array();
$av3=array();
$av4=array();

for($i=0;$i<$ujen;$i++){
$kv1[$qv1[$i][0]][]=$qv1[$i][1];
$kv2[$qv2[$i][0]][]=$qv2[$i][1];
$kv3[$qv3[$i][0]][]=$qv3[$i][1];
$kv4[$qv4[$i][0]][]=$qv4[$i][1];
}
//print_r($kv1);
for($j=0;$j<$ujen;$j++){
$bv1[$j]=array_sum($kv1[$cuj[$j]]);
$bv2[$j]=array_sum($kv2[$cuj[$j]]);
$bv3[$j]=array_sum($kv3[$cuj[$j]]);
$bv4[$j]=array_sum($kv4[$cuj[$j]]);
array_push($av1,$bv1[$j]);
array_push($av2,$bv2[$j]);
array_push($av3,$bv3[$j]);
array_push($av4,$bv4[$j]);
}

//=====================================
//print_r($av1);
//=======================
//tabel saji kolonisasi
//========================
for($p=0;$p<$ujen;$p++){
echo”<tr bgcolor=#”.($p%2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$p]</td>
<td align=center>$ar1[$p]</td>
<td>$av1[$p]</td>
<td align=center>$ar2[$p]</td>
<td>$av2[$p]</d>
<td align=center>$ar3[$p]</td>
<td>$av3[$p]</td>
<td align=center>$ar4[$p]</td>
<td>$av4[$p]</td>
</tr>”;
}
?>
</table>
<br><br>
<center>~~~~INDEKS-INDEKSAN NGACO~~~~~</certer>
<br><br>
<table border=”0″ width=”100%” cellspacing=”1″ cellpadding=”0″ id=”tabel4″>
<tr bgcolor=”#ccccff”>
<th>nama jenis</th>
<th>Jumlah Ind</th>
<th>ni/N</th>
<th>ln(ni/N)</th>
<th>D</th>
<!– <th>R1</th>
<th>E1</th> –>
<th>H</th>
</tr>

<?php
//=======================================
//========Perhitungan Index Dsb==========
//======================================
/*
$len=M_LN10*12;
for($j=0;$j<$ujen;J++){
print_r($jon[$cuj[$j]]);}
*/
$nop=array_values($jon);
//print_r($nop);
//===perhitungan ni/n==========
$as=array_sum($nop);
$np=array();
for($j=0;$j<$ujen;$j++){
$npn[$j]=$nop[$j]/$as;
$np[]=$npn[$j];
}
//print_r($np);
//perhitungan=======ln ni/n======
$lon=array();
for($i=0;$i<$ujen;$i++){
$ln[$i]=log($np[$i]);
$lon[]=$ln[$i];
}

//$cob=log(0.0120481927710843);
//print_r($cob);
//===================dominasi jenis=======
$doj=array();
for($j=0;$j<$ujen;$j++){
$dj[$j]=$np[$j]*$np[$j];
$doj[]=$dj[$j];
}
//=========H aksen======================
$hak=array();
for($i=0;$i<$ujen;$i++){
$hk[$i]=(-1)*$np[$i]*$lon[$i];
$hak[]=$hk[$i];
}
//========nilai H==============
$H=array_sum($hak);

//========nilai R1===============
$R1=($ujen-1)/log($as);

//==========nilai E1============
$E1=$H/log($ujen);

//==========nilai D1===============
$D1=array_sum($doj);

//print_r($hak);
//=======================================
//=========Tabel Saji===================
//=======================================
for($i=0;$i<$ujen;$i++){
echo”<tr bgcolor=#”.($i%2 ? “f0f0f0″:”cccccc”).”>
<td align=center>$cuj[$i]</td>
<td align=center>$nop[$i]</td>
<td align=center>$np[$i]</td>
<td align=center>$lon[$i]</td>
<td align=center>$doj[$i]</td>
<td align=center>$hak[$i]</td>
</tr>”;
}
echo” </table><br><br>”;
echo”<table border=\”1\” width=\”80%\” cellspacing=\”1\” cellpadding=\”0\”>
<tr bgcolor=#ccccff>
<th>Index keanekaragaman Shannon-Wiener</th>
<th>Index Kekayaan Margalef</th>
<th>index kemerataan</th>
<th>Dominasi</th>
<tr>
<tr bgcolor=#cccccc>
<th>$H</th>
<th>$R1</th>
<th>$E1</th>
<th>$D1</th>
</tr>
“;

?>
</table>

</body>
</html>

masih banyak kekurangan di sana sini, sedang di tambal kanan kiri. tabel yang digunakan dalam mysql ada 5 field yaitu PU,Jenis,Keliling,Tinggi_Total,Tinggi bebas_cabang. skrip akan mulai ngaco pada bagian kolonisasi. sampai sekarang masih dalam tahap tambal kanan kiri. semoga saja dapat membantu bagi yang membutuhkan [dengan ikut menambal tentunya untuk hasil yang lebih akurat.]^_^.

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s