getConnection(); $off = new office($db); $stmtoff = $off->off_read(); $numoff = $stmtoff->rowCount(); // Check if the form has been submitted if (isset($_POST['save'])) { // Capture the form data $branch_id = $_POST['offbranch']; $designation = $_POST['dg_name']; // Check if the branch is selected and designation is entered if ($branch_id != '-1' && !empty($designation)) { // Prepare the query to insert data into acts_designation table $query = "INSERT INTO acts_designation (branch_id, dg_name) VALUES (:branch_id, :dg_name)"; // Prepare statement $stmt = $db->prepare($query); // Bind the parameters $stmt->bindParam(':branch_id', $branch_id); $stmt->bindParam(':dg_name', $designation); // Execute the query if ($stmt->execute()) { // Success: Data saved successfully echo ""; } else { // Error: Failed to insert data echo ""; } } else { // Error: Validation failed echo ""; } } ?> STATS
Selected Designation
Total Employees: 0
Add New Employee
prepare($query); $stmt->bindParam(':branch_id', $branch_id); $stmt->execute(); $designations = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($designations) { echo"
"; echo ""; foreach ($designations as $designation) { // Fetch branch name from branch table $branchQuery = "SELECT brch_name FROM acts_branch WHERE brch_id = :branch_id"; $branchStmt = $db->prepare($branchQuery); $branchStmt->bindParam(':branch_id', $designation['branch_id']); $branchStmt->execute(); $branchData = $branchStmt->fetch(PDO::FETCH_ASSOC); // Display the designation in the table echo ""; } echo "
Branch Name Designation Name Action
" . $branchData['brch_name'] . " " . $designation['dg_name'] . "
"; echo "
"; } else { echo "

No designations found for this branch.

"; } } else { echo "

Please select a branch.

"; } }else{ echo "

No results to display!

"; } // Delete Logic if (isset($_GET['delete'])) { $designation_id = $_GET['delete']; // Prepare query to delete the designation $deleteQuery = "DELETE FROM acts_designation WHERE dg_id = :designation_id"; $deleteStmt = $db->prepare($deleteQuery); $deleteStmt->bindParam(':designation_id', $designation_id); if ($deleteStmt->execute()) { // Show success message echo ""; } else { // Show failure message echo ""; } } ?>

Fill the form for Add New Designation