<?php
	require_once 'dbconfig.php';

if(isset($_POST['selectedIds'])) {
    $selectedIds = $_POST['selectedIds'];
 
        foreach($selectedIds as $id) {
            // Delete from mobileorders table
            $stmt_delete_mobileorders = $DB_con->prepare('DELETE FROM mobileorders WHERE order_id = :order_id');
            $stmt_delete_mobileorders->bindParam(':order_id', $id);
            $stmt_delete_mobileorders->execute();
            
            // // Delete from mobiletemporarycart table
            $stmt_delete_mobiletemporarycart = $DB_con->prepare('DELETE FROM mobiletemporarycart WHERE orderid = :order_id');
            $stmt_delete_mobiletemporarycart->bindParam(':order_id', $id);
            $stmt_delete_mobiletemporarycart->execute();
            
            // // Delete from invoice_other_details table
            $stmt_delete_invoice_other_details = $DB_con->prepare('DELETE FROM invoice_other_details WHERE order_id = :order_id');
            $stmt_delete_invoice_other_details->bindParam(':order_id', $id);
            $stmt_delete_invoice_other_details->execute();
        }

    echo 'Rows deleted successfully';
} else {
    echo 'Error: No rows selected for deletion';
}
?>

