-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarksheet.php
More file actions
66 lines (60 loc) · 1.76 KB
/
Copy pathmarksheet.php
File metadata and controls
66 lines (60 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<title>Student Marksheet Generator</title>
<style>
table {
border-collapse: collapse;
width: 60%;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
h2 {
text-align: center;
}
</style>
</head>
<body>
<h2>Student Marksheet</h2>
<?php
$students = [
[
"Name" => "Aman",
"Subjects" => ["Math" => 85, "Science" => 78, "English" => 92]
],
[
"Name" => "Ravi",
"Subjects" => ["Math" => 90, "Science" => 88, "English" => 75]
],
[
"Name" => "Sita",
"Subjects" => ["Math" => 70, "Science" => 65, "English" => 80]
]
];
foreach ($students as $student) {
echo "<table>";
echo "<tr><th colspan='3'>".$student['Name']."</th></tr>";
echo "<tr><th>Subject</th><th>Marks</th><th>Result</th></tr>";
$total = 0;
$count = count($student['Subjects']);
foreach ($student['Subjects'] as $subject => $marks) {
$total += $marks;
$result = ($marks >= 40) ? "Pass" : "Fail";
echo "<tr><td>$subject</td><td>$marks</td><td>$result</td></tr>";
}
$average = $total / $count;
$finalResult = ($average >= 40) ? "Pass" : "Fail";
echo "<tr><th>Total</th><th colspan='2'>$total</th></tr>";
echo "<tr><th>Average</th><th colspan='2'>$average ($finalResult)</th></tr>";
echo "</table><br>";
}
?>
</body>
</html>