175. PHP Program to Read the Student marks and find the Class.
How does this program work?
- In this program you are going to learn about how to read the student marks and find the class using PHP.
- In this program subject marks will stored in different variables.
- After that we can find out the Total, Average and Class.
Here is the code
<html>
<head>
<title>PHP Program To Read the Student marks and find the Class</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter Telugu marks"/> </td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter Hindi marks"/> </td>
</tr>
<tr>
<td> <input type="text" name="num3" value="" placeholder="Enter English marks"/> </td>
</tr>
<tr>
<td> <input type="text" name="num4" value="" placeholder="Enter Maths marks"/> </td>
</tr>
<tr>
<td> <input type="text" name="num5" value="" placeholder="Enter Science marks"/> </td>
</tr>
<tr>
<td> <input type="text" name="num6" value="" placeholder="Enter Social marks"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$t = $_POST['num1'];
$h = $_POST['num2'];
$e = $_POST['num3'];
$m = $_POST['num4'];
$sc = $_POST['num5'];
$so = $_POST['num6'];
$precision = 4;
$total = $t+$h+$e+$m+$sc+$so;
$avg = $total/6;
echo("Total Marks obtained = ".$total)."</br>";
echo("Average = ".number_format($avg, $precision))."</br>";
if($t<35||$h<35||$e<35||$m<35||$sc<35||$so<35)
{
echo "Fail";
}
else
if($avg>=35 && $avg<50)
{
echo "III class";
}
else
if($avg>=50 && $avg<70)
{
echo "II class";
}
else
if($avg>=70 && $avg<85)
{
echo "I class";
}
else
echo( "Distinction");
return 0;
}
?>
</body>
</html>