-
Notifications
You must be signed in to change notification settings - Fork 0
/
ass_9 (1).php
executable file
·72 lines (49 loc) · 1.93 KB
/
ass_9 (1).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
<!DOCTYPE html>
<html>
<head>
<title>Input Form</title>
</head>
<body>
<h1>Input Form</h1>
<form action ="display.php" method="POST">
<label for="year">Enter Year:</label>
<input type="textbox" name="year" id="year" required><br><br>
<label>Class Grades:</label><br>
<input type="radio" name="grades" value="First Class" id="firstClass">
<label for="firstClass">First Class</label><br>
<input type="radio" name="grades" value="Second Class" id="secondClass">
<label for="secondClass">Second Class</label><br>
<input type="radio" name="grades" value="Pass" id="pass">
<label for="pass">Pass</label><br>
<input type="radio" name="grades" value="Fail" id="fail">
<label for="fail">Fail</label><br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
$conn = mysqli_connect('localhost', 'root', '', '');
if(isset($_POST['submit'])) {
$year = $_REQUEST['year'];
$grades = $_REQUEST['grades'];
mysqli_select_db($conn,"university");
$sql = 'SELECT * FROM student WHERE passingyear = ? AND classgrade = ?';
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 'is', $year, $grades);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo '<p>Roll No: ' . $row['rollno'] . '</p>';
echo '<p>Name: ' . $row['studname'] . '</p>';
echo '<p>Department: ' . $row['studdept'] . '</p>';
echo '<p>Passing Year: ' . $row['passingyear'] . '</p>';
echo '<p>Class Grades: ' . $row['classgrade'] . '</p>';
echo '<hr>';
}
} else {
echo 'No records found';
}
mysqli_close($conn);
}
?>