-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanageresult.php
168 lines (151 loc) · 6.01 KB
/
manageresult.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./css/home.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="./css/form.css">
<title>Dashboard</title>
<style>
.heading {
font-size: 40px;
font-family: cursive;
color:yellow;
}
</style>
</head>
<body>
<div class="title">
<a href="dashboard.php"> <img style="border-radius:34px;height:70px" src="./images/college1.jpg" alt="logo"></a>
<span class="heading">Dashboard</span>
<a href="logout.php" style="color: white"><span class="fa fa-sign-out fa-2x">Logout</span></a>
</div>
<hr>
<div class="nav">
<ul>
<li><a href="homepage.html">HOME</a></a>
</li>
<li class="dropdown" onclick="toggleDisplay('1')">
<a href="" class="dropbtn">Classes  
<span class="fa fa-angle-down"></span>
</a>
<div class="dropdown-content" id="1">
<a href="addclasses.php">Add Class</a>
<a href="manageclass.php">Manage Class</a>
</div>
</li>
<li class="dropdown" onclick="toggleDisplay('2')">
<a href="#" class="dropbtn">Students  
<span class="fa fa-angle-down"></span>
</a>
<div class="dropdown-content" id="2">
<a href="addstudent.php">Add Students</a>
<a href="managestudent.php">Manage Students</a>
</div>
</li>
<li class="dropdown" onclick="toggleDisplay('3')">
<a href="#" class="dropbtn">Results  
<span class="fa fa-angle-down"></span>
</a>
<div class="dropdown-content" id="3">
<a href="addresult.php">Add Results</a>
<a href="manageresult.php">Manage Results</a>
</div>
</li>
</ul>
</div>
<hr>
<div class="main">
<br><br>
<form action="" method="post">
<fieldset>
<legend>Delete Result</legend>
<?php
include('init.php');
include('session.php');
$class_result=mysqli_query($conn,"SELECT `name` FROM `class`");
echo '<select name="class_name">';
echo '<option selected disabled>Select Class</option>';
while($row = mysqli_fetch_array($class_result)){
$display=$row['name'];
echo '<option value="'.$display.'">'.$display.'</option>';
}
echo'</select>'
?>
<input type="text" name="rno" placeholder="Roll No">
<input type="submit" value="Delete">
</fieldset>
</form>
<br><br>
<form action="" method="post">
<fieldset>
<legend>Update Result</legend>
<?php
$class_result=mysqli_query($conn,"SELECT `name` FROM `class`");
echo '<select name="class">';
echo '<option selected disabled>Select Class</option>';
while($row = mysqli_fetch_array($class_result)){
$display=$row['name'];
echo '<option value="'.$display.'">'.$display.'</option>';
}
echo'</select>'
?>
<input type="text" name="rn" placeholder="Roll No">
<input type="text" name="p1" id="" placeholder="Paper 1">
<input type="text" name="p2" id="" placeholder="Paper 2">
<input type="text" name="p3" id="" placeholder="Paper 3">
<input type="text" name="p4" id="" placeholder="Paper 4">
<input type="text" name="p5" id="" placeholder="Paper 5">
<input type="submit" value="Update">
</fieldset>
</form>
</div>
<footer style="background-color:gray;color:white;margin:100px 0px 0px 0px;text-align:center;height:36px;padding:30px">
<div>
<p>Designed By - VIPUL KUMAR <br>LetsGrowMore</p>
</div>
</footer>
</body>
</html>
<?php
if(isset($_POST['class_name'],$_POST['rno'])) {
$class_name=$_POST['class_name'];
$rno=$_POST['rno'];
echo $class_name;
echo $rno;
$delete_sql=mysqli_query($conn,"DELETE from `result` where `rno`='$rno' and `class`='$class_name'");
if(!$delete_sql){
echo '<script language="javascript">';
echo 'alert("Not available")';
echo '</script>';
} else {
echo '<script language="javascript">';
echo 'alert("Deleted")';
echo '</script>';
}
}
if(isset($_POST['rn'],$_POST['p1'],$_POST['p2'],$_POST['p3'],$_POST['p4'],$_POST['p5'],$_POST['class'])) {
$rno=$_POST['rn'];
$class_name=$_POST['class'];
$p1=(int)$_POST['p1'];
$p2=(int)$_POST['p2'];
$p3=(int)$_POST['p3'];
$p4=(int)$_POST['p4'];
$p5=(int)$_POST['p5'];
$marks=$p1+$p2+$p3+$p4+$p5;
$percentage=$marks/5;
$sql="UPDATE `result` SET `p1`='$p1',`p2`='$p2',`p3`='$p3',`p4`='$p4',`p5`='$p5',`marks`='$marks',`percentage`='$percentage' WHERE `rno`='$rno' and `class`='$class_name'";
$update_sql=mysqli_query($conn,$sql);
if(!$update_sql){
echo '<script language="javascript">';
echo 'alert("Invalid Details")';
echo '</script>';
} else {
echo '<script language="javascript">';
echo 'alert("Updated")';
echo '</script>';
}
}
?>