Viewing file: edit_result.php (3.57 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html> <html lang="en">
<?php include 'head.php';?> <style> table { border-collapse: collapse; width: 100%; margin-top: 20px; }
table, th, td { border: 1px solid #ddd; }
th, td { padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; } .custom-image { width: 100px; height: 100px; } </style> <body>
<!-- ======= Header ======= --> <?php include 'menubar.php';?>
<?php include 'sidebar.php';?>
<main id="main" class="main">
<?php include 'connect.php';
if (!isset($_GET['id']) || empty($_GET['id'])) { die("❌ Invalid Request"); }
$id = intval($_GET['id']);
// Fetch existing record $sql = "SELECT * FROM test_result WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result();
if ($result->num_rows === 0) { die("❌ Record not found"); }
$row = $result->fetch_assoc();
// Update record when form is submitted if ($_SERVER['REQUEST_METHOD'] == "POST") { $classes = $_POST['classes']; $section = $_POST['section']; $marks = $_POST['marks']; $paper_code = $_POST['paper_code']; $exam_date = $_POST['exam_date'];
$update_sql = "UPDATE test_result SET classes=?, section=?, marks=?, paper_code=?, exam_date=? WHERE id=?"; $stmt_update = $conn->prepare($update_sql); $stmt_update->bind_param("ssissi", $classes, $section, $marks, $paper_code, $exam_date, $id);
if ($stmt_update->execute()) { echo "<script>alert('✅ Record updated successfully!'); window.location='exam_results.php';</script>"; } else { echo "❌ Error updating record: " . $conn->error; } } ?>
<!DOCTYPE html> <html> <head> <title>Edit Result</title> <style> body { font-family: Arial, sans-serif; background: #f5f6f7; } .container { width: 50%; margin: auto; background: white; padding: 20px; box-shadow: 0px 0px 10px rgba(0,0,0,0.3); margin-top: 50px; border-radius: 8px; } h2 { text-align: center; margin-bottom: 20px; } label { display: block; margin-top: 10px; font-weight: bold; } input, select { width: 100%; padding: 8px; margin-top: 5px; border-radius: 5px; border: 1px solid #ccc; } button { margin-top: 20px; padding: 10px 15px; background: #007BFF; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background: #0056b3; } </style> </head> <body> <div class="container"> <h2>Edit Exam Result</h2> <form method="POST"> <label>Roll No:</label> <input type="text" value="<?= htmlspecialchars($row['roll_no']) ?>" disabled>
<label>Name:</label> <input type="text" value="<?= htmlspecialchars($row['name']) ?>" disabled>
<label>Class:</label> <input type="text" name="classes" value="<?= htmlspecialchars($row['classes']) ?>" required>
<label>Section:</label> <input type="text" name="section" value="<?= htmlspecialchars($row['section']) ?>" required>
<label>Marks:</label> <input type="number" name="marks" value="<?= htmlspecialchars($row['marks']) ?>" required>
<label>Paper Code:</label> <input type="text" name="paper_code" value="<?= htmlspecialchars($row['paper_code']) ?>" required>
<label>Exam Date:</label> <input type="date" name="exam_date" value="<?= htmlspecialchars($row['exam_date']) ?>" required>
<button type="submit">Update</button> </form> </div> </body> </html>
</main><!-- End #main -->
<?php include 'footer.php';?>
</body>
</html>
|