PHP sop4 pg-2. Total marks exam
<!DOCTYPE html>
<head><title>how to use array</title>
<?php
function display_marks()
{
$eng=$_POST["eng"];
$phy=$_POST["phy"];
$chem=$_POST["chem"];
$bio=$_POST["bio"];
$math=$_POST["math"];
$it=$_POST["it"];
$subject = array("English", "Physics", "Chemistry", "Biology", "Mathematics","IT");
$subject['English']="$eng";
$subject['Physics']="$phy";
$subject['Chemistry']="$chem";
$subject['Biology']="$bio";
$subject['Mathematics']="$math";
$subject['IT']="$it";
$i=1;$tot=0;
foreach($subject as $value)
{ echo "$value =$subject[$value] <br>"; $tot = $tot + $subject[$value];
$i=$i+1;
if($i > 6)
{ break;
}
} echo "<b> Your Total marks = $tot <br>"; echo "<b> Your percentage is = $perc %";
$perc=$tot/6;
}
display_marks(); ?>
</head>
<body>
</body></html>
Comments
Post a Comment