The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Employee minimal
By Guest on 26th July 2024 08:03:42 AM | Syntax: PYTHON | Views: 27



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Search Employee</title>
  6. </head>
  7. <body>
  8.     <h2>Search Employee</h2>
  9.     <form method="post">
  10.         Enter Employee Number: <input type="text" name="empno">
  11.         <input type="submit" value="Search">
  12.     </form>
  13.  
  14.     <?php
  15.     // Check if form is submitted
  16.     if ($_SERVER["REQUEST_METHOD"] == "POST") {
  17.         // Retrieve entered EmpNo
  18.         $empno = $_POST['empno'];
  19.  
  20.         // Database credentials
  21.         $servername = "localhost";
  22.         $username = "your_username";
  23.         $password = "your_password";
  24.         $dbname = "employee_db";
  25.  
  26.         // Create connection
  27.         $conn = new mysqli($servername, $username, $password, $dbname);
  28.  
  29.         // Check connection
  30.         if ($conn->connect_error) {
  31.             die("Connection failed: " . $conn->connect_error);
  32.         }
  33.  
  34.         // Prepare SQL query
  35.         $sql = "SELECT * FROM employees WHERE EmpNo = ?";
  36.         $stmt = $conn->prepare($sql);
  37.         $stmt->bind_param("i", $empno);
  38.         $stmt->execute();
  39.         $result = $stmt->get_result();
  40.  
  41.         // Display results in a table
  42.         if ($result->num_rows > 0) {
  43.             echo "<h3>Employee Details</h3>";
  44.             echo "<table border='1'>";
  45.             echo "<tr><th>EmpNo</th><th>EmpName</th><th>Designation</th><th>DOJ</th><th>BasicPay</th><th>DA</th></tr>";
  46.             while ($row = $result->fetch_assoc()) {
  47.                 echo "<tr>";
  48.                 echo "<td>" . $row['EmpNo'] . "</td>";
  49.                 echo "<td>" . $row['EmpName'] . "</td>";
  50.                 echo "<td>" . $row['Designation'] . "</td>";
  51.                 echo "<td>" . $row['DOJ'] . "</td>";
  52.                 echo "<td>" . $row['BasicPay'] . "</td>";
  53.                 echo "<td>" . $row['DA'] . "</td>";
  54.                 echo "</tr>";
  55.             }
  56.             echo "</table>";
  57.         } else {
  58.             echo "<p>No employee found with EmpNo: $empno</p>";
  59.         }
  60.  
  61.         // Close statement and connection
  62.         $stmt->close();
  63.         $conn->close();
  64.     }
  65.     ?>
  66. </body>
  67. </html>





employee minimal