Viewing file: print_marksheet.php (5.71 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"> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script> <script src="https://printjs-4de6.kxcdn.com/print.min.js"></script> <link rel="stylesheet" href="https://printjs-4de6.kxcdn.com/print.min.css">
<?php include 'connect.php';
// Get student ID $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if ($id <= 0) { die("❌ Invalid ID."); }
// Fetch student result $sql = "SELECT roll_no, name, classes, section, marks, exam_date, paper_code 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("❌ No result found for this ID."); } $row = $result->fetch_assoc(); ?>
<!DOCTYPE html> <html> <head> <title>Marksheet - ITCE</title> <style> body { font-family: Arial, sans-serif; margin: 40px; background: #fff; } .marksheet { border: 2px solid #000; padding: 20px; width: 750px; margin: auto; background: #fff; } .header { text-align: center; } .header h2 { margin: 0; font-size: 24px; } .header h4 { margin: 3px 0; font-size: 14px; } .info { margin: 20px 0; } .info table { width: 100%; border-collapse: collapse; } .info td { padding: 6px; font-size: 15px; width: 50%; vertical-align: top; } .result { margin-top: 20px; } .result table { width: 100%; border-collapse: collapse; } .result th, .result td { border: 1px solid #000; padding: 10px; text-align: center; font-size: 15px; word-wrap: break-word; } .footer { margin-top: 60px; display: table; width: 100%; text-align: center; } .footer div { display: table-cell; width: 33%; font-size: 14px; vertical-align: bottom; } .print-btn { margin-top: 20px; text-align: center; } .print-btn button { padding: 10px 20px; font-size: 16px; cursor: pointer; } @media print { .print-btn { display: none; } body { margin: 0; } } </style> </head> <body> <div class="marksheet"> <div class="header"> <h2><b>ITCE</b></h2> <h4>Sabzi Mandi, Saraimeer</h4> <h4>Azamgarh, Pin 276305</h4> <h4>Phone: 9415257855, 9451515567</h4> <h4>Email: itcecomputer@outlook.com | infysystechnologies@outlook.com</h4> <hr> <h3>Marksheet</h3> </div> <br><br><br><br><br><br><br>
<div class="info"> <table> <tr> <td><b>Roll No:</b> <?php echo $row['roll_no']; ?></td> <td><b>Name:</b> <?php echo $row['name']; ?></td> </tr> <tr> <td><b>Class:</b> <?php echo $row['classes']; ?> - <?php echo $row['section']; ?></td> <td><b>Exam Date:</b> <?php echo date("d-m-Y", strtotime($row['exam_date'])); ?></td> </tr> <tr> <td><b>Paper Code:</b> <?php echo $row['paper_code']; ?></td> <td><b>Maximum Marks:</b> 100</td> </tr> </table> </div>
<div class="result"> <table> <tr> <th>Subject</th> <th>Marks Obtained</th> <th>Maximum Marks</th> <th>Percentage</th> <th>Result</th> </tr> <tr> <td><?php echo $row['paper_code']; ?></td> <td><?php echo $row['marks']; ?></td> <td>100</td> <td><?php echo round(($row['marks'] / 100) * 100, 2); ?>%</td> <td> <?php if ($row['marks'] >= 33) { echo "PASS"; } else { echo "FAIL"; } ?> </td> </tr> </table> </div>
<div class="footer"> <div><b>Student Signature</b></div> <div><b>Teacher Signature</b></div> <div><b>Principal Signature</b></div> </div>
</div> </body> </html>
<div class="print-btn"> <button onclick="printMarksheet()">🖨 Print Marksheet</button> </div>
<script> function printMarksheet() { let element = document.querySelector(".marksheet");
// Convert marksheet to image html2canvas(element, { scale: 2 }).then(canvas => { let imageData = canvas.toDataURL("image/png");
// Use printJS to print the image printJS({ printable: imageData, type: 'image', documentTitle: 'Marksheet - ITCE' }); }); } </script>
</main><!-- End #main -->
<?php include 'footer.php';?>
</body>
</html>
|