Posted: Tue Mar 02, 2004 9:14 pm
opps, sorry, that should have been :
foreach(explode(',', $_POST['gagal']) as $gag){
foreach(explode(',', $_POST['gagal']) as $gag){
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
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=explode(',', $_POST["gagal"]);
//$dt1=$gagal*$bilInspection*$bd*$bt3+$pb;
foreach(explode(',', $_POST['gagal']) as $gag){
$dt1[]=($gag*$bilInspection*$bd*$bt3)+$pb;
}
$dt2=$bilInspection+$pb;
$minDownTime=$dt1/$dt2;
$minDownTime1=number_format($minDownTime, 5, '.', '');
echo "<pre>";
print_r($dt1);
echo "</pre>";
$SQLupd=mysql_query("UPDATE mindowntime SET Dn = '$minDownTime1' where n='$bilInspection'");
}which will first add up all those individual calculations
Code: Select all
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=explode(',', $_POST["gagal"]);
//$dt1=$gagal*$bilInspection*$bd*$bt3+$pb;
foreach(explode(',', $_POST['gagal']) as $gag){
$dt1[]=($gag*$bilInspection*$bd*$bt3)+$pb;
}
$dt2=$bilInspection+$pb;
$minDownTime=$dt1/$dt2;
$minDownTime1=number_format($minDownTime, 5, '.', '');
echo "<pre>";
print_r($dt1);
echo "</pre>";
$SQLupd=mysql_query("UPDATE mindowntime SET Dn = '$minDownTime1' where n='$bilInspection'");
}Code: Select all
{
$MTTF=$_POST["MTTF"];
$bd=$_POST["purataMasaBD"];
$pb=$_POST["purataMasaPPM"];
$bilInspection=$periksa["n"];
$bt1=exp(-$MTTF*$bilInspection);
$bt2=$bt1/($MTTF/$bilInspection);
$bt3=1-$bt2;
foreach(explode(',', $_POST['gagal']) as $gag){
$dt1=($gag*$bilInspection*$bd*$bt3)+$pb;
$dt2=$bilInspection+$pb;
$minDownTime=$dt1/$dt2;
$minDownTime1=number_format($minDownTime, 5, '.', '');
echo "<pre>";
print_r($dt1);
echo "</pre>";
$SQLupd=mysql_query("UPDATE mindowntime SET Dn = '$minDownTime1' where n='$bilInspection'");
}
}Code: Select all
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000Code: Select all
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000
string(71) "0.032,0.036,0.032,0.033,0.032,0.167,0.000,0.065,0.067,0.032,0.033,0.000"
0.032
0.036
0.032
0.033
0.032
0.167
0.000
0.065
0.067
0.032
0.033
0.000