-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
82 lines (78 loc) · 1.77 KB
/
function.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
function subjectList(){
$array = array(
"Data Communication",
"Computer Achitecture",
"Database",
"English",
"Cplusplus",
"Data Structure",
"Average",
"Grade"
);
for ($i=0; $i <count($array) ; $i++) {
echo "<th>$array[$i]</th>";
}
}
function Average($dc,$ca,$db,$eng,$cpp,$ds){
$dc = $_POST['DC'];
$ca = $_POST['CA'];
$db = $_POST['DB'];
$eng = $_POST['ENG'];
$cpp = $_POST['CPP'];
$ds = $_POST['DS'];
if (isset($_POST['submit'])){
$result = ($dc+$ca+$db+$eng+$cpp+$ds)/6;
return $result;
}
}
function Grade(){
if (Average() > 90) {
$grade = ' A';
}elseif(Average() >= 90 || Average()>80){
$grade = ' B';
}elseif(Average()>=80 || Average()>70){
$grade = ' C';
}elseif(Average()>=70 || Average()>60){
$grade = ' D';
}elseif(Average()>=60 || Average()>=50){
$grade = ' E';
}else{
$grade = 'F';
}
if (isset($_POST['submit'])) {
return $grade;
}else{
echo ' ';
}
}
function Result(){
$array = array(
$_POST['DC'],
$_POST['CA'],
$_POST['DB'],
$_POST['ENG'],
$_POST['CPP'],
$_POST['DS'],
Average(),
Grade()
);
for ($i=0; $i <count($array); $i++) {
if (empty($_POST['DC']&&$_POST['CA']&&$_POST['DB']&&$_POST['ENG']&&$_POST['CPP']&&$_POST['DS'])) {
echo ' ';
}else {
echo "<th>$array[$i]</th>";
}
}
}
function Validate($error){
if (isset($_POST['submit'])) {
if (empty($_POST['DC']&&$_POST['CA']&&$_POST['DB']&&$_POST['ENG']&&$_POST['CPP']&&$_POST['DS'])) {
$error = "<p style='text-align:center;color:red;'>All field *require<p>";
}else{
Average();
}
}
return $error;
}
?>