-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_prog.php
93 lines (91 loc) · 2.11 KB
/
edit_prog.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
<!DOCTYPE html>
<html>
<head>
<style>
#table{
margin-top:30px;
font-size:20px;
text-transform: uppercase;
}
</style>
</head>
<?php
@require "navbar2.php";
require 'connect.php';
$str='manik';
$num=0;
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
$sql = "SELECT * FROM `subwise` WHERE `subject`='programming'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$num+=1;
$str.=$num;
$rollno = $row['rollno'];
$name = $row['name'];
$present = $_POST["$str"];
if($present>=75){
$present=75;
}
$absent = 75-$present;
$percent = (($present)*100)/75;
$sqll = "UPDATE `subwise` SET
`present`='$present',`absent`='$absent',`percent`='$percent' WHERE `subject`='programming' AND `rollno`='$rollno'";
if ($conn->query($sqll) === TRUE) {
} else {
echo "Error updating record: " . $conn->error;
}
}
} else {
echo "0 results";
}
echo "Record updated succesfully";
}
?>
<body>
<div id='table'><br>
<table style="width:99.9%"border="5">
<form method="POST" action="edit_prog.php">
<?php
include 'connect.php';
$sql = "SELECT * FROM `subwise` WHERE `subject`='programming'";
$result = $conn->query($sql);
echo '<tr>';
echo '<th>SEMESTER</th>';
echo '<th>GROUP</th>';
echo '<th>ROLL NO</th>';
echo '<th>NAME</th>';
echo '<th>SUBJECT</th>';
echo '<th>NO.OF.DAYS Present</th>';
echo '</tr>';
// output data of each row
$str='manik';
$num=0;
while($row = $result->fetch_assoc()) {
$num+=1;
$str.=$num;
$semester=1;
$group = 'CSE';
$roll = $row['rollno'];
$name = $row['name'];
$subject = $row['subject'];
$present = $row['present'];
$absent = $row['absent'];
$percent = $row['percent'];
echo '<tr>';
echo "<td>$semester</td>";
echo "<td>$group</td>";
echo "<td>$roll</td>";
echo "<td>$name</td>";
echo "<td>$subject</td>";
echo "<td><input type='int' name='$str' value=$present></td>";
echo '</tr>';
}
?>
<input type="submit" name="submit" value="save the changes">
</form>
</table>
</div>
</body>
</html>