how to manipulate an array???
Posted: Tue Mar 02, 2004 11:40 am
this a snippet from my 1st page:
notice that the $array1 is a collection an array..lets say its 1,2,3,4...12
and then i post it to the second page to manipulate the array...
and heres the snippet:
notice that the $gagal is taken from the 1st page before..
but when i echo the array,it print out Array Array Array Array Array..Array
it suppose to print out certain numbers,not the Array words...
and how to manipulate the array that i post from the 1st page??
lets say the array 1,2,3...12..
and on the first loop i want to manipulate the 1...and the second i want to manipulate the 2...and so on...do u understand??
sorry for my poor english..
FYI,i tried the SESSION way...
but it gives me "unsupported operand" error??
so pls array experts,HELP me!!!
Code: Select all
while($periksa2=mysql_fetch_array($viewCheck2, MYSQL_ASSOC))
{
?>
<TR>
<TD><font face="verdana" size="2"><?php echo $periksa2["bulan"]; ?></font></TD>
<TD><font face="verdana" size="2"><?php echo $periksa2["bilHari"]; ?></font></TD>
<TD><font face="verdana" size="2"><?php echo $periksa2["jumlah"]; ?></font></TD>
<?php
$jumlahRosak=trim($periksa2["jumlah"]);
$bilHari=trim($periksa2["bilHari"]);
$failureRate=($jumlahRosak/$bilHari);
$failure=number_format($failureRate, 3, '.', '')
?>
<TD><font face="verdana" size="2"><?php echo $failure; ?></font></TD>
<?php
$SQLupd=query("UPDATE tempfailure SET failureRate = '$failure' WHERE bulan = '{$periksa2["bulan"]}'", $link, __LINE__, __FILE__);
$array1[]=$failure;
?>
</TR>
<?php
}
?>
</table>
<input type="hidden" name="purataMasaBD" value="<?=$purataMasaBD1?>">
<input type="hidden" name="lambda" value="<?=$lambda1?>">
<input type="hidden" name="purataMasaPPM" value="<?=$purataMasaPPM2?>">
<input type="hidden" name="MTTF" value="<?=$MTTF1?>">
<input type="hidden" name="gagal" value="<?=$array1?>">
<input type="hidden" name="noTag" value="<?=$_POST["noTag"]?>">
<input type="hidden" name="year" value="<?=$_POST["year"]?>">
<input type="hidden" name="bil" value="<?=$bil?>">and then i post it to the second page to manipulate the array...
and heres the snippet:
Code: Select all
<?php
$viewCheck=query("SELECT * FROM mindowntime order by id", $link, __LINE__, __FILE__);
while($periksa=mysql_fetch_array($viewCheck))
{
$MTTF=$_POST["MTTF"];
$bd=$_POST["purataMasaBD"];
$pb=$_POST["purataMasaPPM"];
$bilInspection=$periksa["n"];
$bt1=exp(-$MTTF*$bilInspection);
$bt2=$bt1/($MTTF/$bilInspection);
$bt3=1-$bt2;
$gagal=$_POST["gagal"];
$dt1=$gagal*$bilInspection*$bd*$bt3+$pb;
$dt2=$bilInspection+$pb;
$minDownTime=$dt1/$dt2;
$minDownTime1=number_format($minDownTime, 5, '.', '');
echo $gagal."\n";
$SQLupd=mysql_query("UPDATE mindowntime SET Dn = '$minDownTime1' where n='$bilInspection'");
}
?>
<CENTER>
<?phpbut when i echo the array,it print out Array Array Array Array Array..Array
it suppose to print out certain numbers,not the Array words...
and how to manipulate the array that i post from the 1st page??
lets say the array 1,2,3...12..
and on the first loop i want to manipulate the 1...and the second i want to manipulate the 2...and so on...do u understand??
sorry for my poor english..
FYI,i tried the SESSION way...
but it gives me "unsupported operand" error??
so pls array experts,HELP me!!!