Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Student Records</title>
- </head>
- <body>
- <h2>Search Student Record</h2>
- <form method="POST">
- Enter Roll Number: <input type="text" name="rollno" required>
- <input type="submit" name="search" value="Search">
- </form>
- <?php
- if (isset($_POST['search'])) {
- $rollno = $_POST['rollno']; // Get roll number from user input
- // Database connection
- $conn = mysqli_connect("localhost", "root", "", "COLLEGE");
- if ($conn->connect_error) {
- die("Connection Failed: " . $conn->connect_error);
- }
- echo "Connected successfully<br>";
- // Prepare SQL query to search for the given Roll Number
- $sql = "SELECT SID, NAME, EMAIL, FEES, DOB FROM STUDENT WHERE SID = ?";
- $stmt = $conn->prepare($sql);
- $stmt->bind_param("s", $rollno);
- $stmt->execute();
- $result = $stmt->get_result();
- // Check if record exists
- if ($result->num_rows > 0) {
- echo "<h3>Record Found:</h3>";
- echo "<table border='1'>
- <tr>
- <th>ID</th>
- <th>NAME</th>
- <th>EMAIL</th>
- <th>FEES</th>
- <th>DOB</th>
- </tr>";
- while ($row = $result->fetch_assoc()) {
- echo "<tr>
- <td>" . $row["SID"] . "</td>
- <td>" . $row["NAME"] . "</td>
- <td>" . $row["EMAIL"] . "</td>
- <td>" . $row["FEES"] . "</td>
- <td>" . $row["DOB"] . "</td>
- </tr>";
- }
- echo "</table>";
- } else {
- echo "<h3>No record found for Roll Number: $rollno</h3>";
- }
- // Close connections
- $stmt->close();
- $conn->close();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement