Change Table Color Based On Calculated Average
<?php
if($_POST["b1"])
{
$eng = $_POST["eng"];
$hin = $_POST["hin"];
$mat = $_POST["mat"];
$pub = $_POST["pun"];
$sum = $eng + $hin + $mat + $pub;
$avg = $sum / 4;
}
?>
<html>
<body>
<form method="post"
action="Lec3.php">
<table border="5"
bgcolor="<?php
if(isset($avg))
{
if($avg
>= 85 )
echo
"Red";
else
if($avg <85 && $avg >=60)
echo "Green";
else
echo "Blue";
}
else
echo
"White";
?>
">
<tr>
<td>Enter Student
Name :-</td>
<td><input
type="text" name="nm"/></td>
</tr>
<tr>
<td>Enter Student
Roll No :-</td>
<td><input
type="text" name="rn"/></td>
</tr>
<tr>
<td>Enter English
Marks :-</td>
<td><input
type="text" name="eng"/></td>
</tr>
<tr>
<td>Enter Hindi Marks :-</td>
<td><input
type="text" name="hin"/></td>
</tr>
<tr>
<td>Enter Maths Marks
:-</td>
<td><input
type="text" name="mat"/></td>
</tr>
<tr>
<td>Enter Punjabi
Marks :-</td>
<td><input
type="text" name="pun"/></td>
</tr>
<tr>
<td colspan="2"><input
type="submit" name="b1"/></td>
</tr>
<tr>
<td>Total Marks
:-</td>
<td><?php
if(isset($sum)){echo $sum;} ?> </td>
</tr>
<tr>
<td>Average
:-</td>
<td> <?php
if(isset($avg)){echo $avg;} ?></td>
</tr>
</table>
</form>
</body> </html>
Change Table Color Based On Calculated Average
Reviewed by Baljeet Singh
on
11:07
Rating:
No comments: