-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.php
89 lines (81 loc) · 2.73 KB
/
student.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
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/student.css">
<title>Result</title>
</head>
<body>
<?php
include("init.php");
if(!isset($_GET['class']))
$class=null;
else
$class=$_GET['class'];
$rn=$_GET['rn'];
// validation
if (empty($class) or empty($rn) or preg_match("/[a-z]/i",$rn)) {
if(empty($class))
echo '<p class="error">Please select your class</p>';
if(empty($rn))
echo '<p class="error">Please enter your roll number</p>';
if(preg_match("/[a-z]/i",$rn))
echo '<p class="error">Please enter valid roll number</p>';
exit();
}
$name_sql=mysqli_query($conn,"SELECT `name` FROM `students` WHERE `rno`='$rn' and `class_name`='$class'");
while($row = mysqli_fetch_assoc($name_sql))
{
$name = $row['name'];
}
$result_sql=mysqli_query($conn,"SELECT `p1`, `p2`, `p3`, `p4`, `p5`, `marks`, `percentage` FROM `result` WHERE `rno`='$rn' and `class`='$class'");
while($row = mysqli_fetch_assoc($result_sql))
{
$p1 = $row['p1'];
$p2 = $row['p2'];
$p3 = $row['p3'];
$p4 = $row['p4'];
$p5 = $row['p5'];
$mark = $row['marks'];
$percentage = $row['percentage'];
}
if(mysqli_num_rows($result_sql)==0){
echo "no result";
exit();
}
?>
<div class="container">
<div class="details">
<span>Name:</span> <?php echo $name ?> <br>
<span>Class:</span> <?php echo $class; ?> <br>
<span>Roll No:</span> <?php echo $rn; ?> <br>
</div>
<div class="main">
<div class="s1">
<p>Subjects</p>
<p>Paper 1</p>
<p>Paper 2</p>
<p>Paper 3</p>
<p>Paper 4</p>
<p>Paper 5</p>
</div>
<div class="s2">
<p>Marks</p>
<?php echo '<p>'.$p1.'</p>';?>
<?php echo '<p>'.$p2.'</p>';?>
<?php echo '<p>'.$p3.'</p>';?>
<?php echo '<p>'.$p4.'</p>';?>
<?php echo '<p>'.$p5.'</p>';?>
</div>
</div>
<div class="result">
<?php echo '<p>Total Marks: '.$mark.'</p>';?>
<?php echo '<p>Percentage: '.$percentage.'%</p>';?>
</div>
<div class="button">
<button onclick="window.print()">Print Result</button>
</div>
</div>
</body>
</html>