Skip to content

Commit

Permalink
Merge pull request #21 from TEAM-7-SAD/SPD-65
Browse files Browse the repository at this point in the history
Spd 65
  • Loading branch information
Carl-Tabuso authored May 10, 2024
2 parents 1d7680c + f2cc524 commit 092754c
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 147 deletions.
26 changes: 26 additions & 0 deletions src/delete-sale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
// Include the database connection file
require_once 'includes/db-connector.php';
// Check if account IDs are provided
if (isset($_POST['saleIds']) && is_array($_POST['saleIds'])) {
// Get the account IDs from the POST data
$saleIds = $_POST['saleIds'];

// Prepare and execute the SQL query to delete selected accounts
$sql = "DELETE FROM user WHERE id IN (" . implode(',', array_fill(0, count($saleIds), '?')) . ")";
$sql = "DELETE FROM transaction WHERE id IN (" . implode(',', array_fill(0, count($saleIds), '?')) . ")";
$stmt = $db->prepare($sql);
$types = str_repeat('i', count($saleIds));
$stmt->bind_param($types, ...$saleIds);
if ($stmt->execute()) {
// If the deletion is successful, return a success response
echo 'success';
} else {
// If an error occurs, return an error response
echo 'error';
}
} else {
// If account IDs are not provided, return an error response
echo 'error';
}
?>
Loading

0 comments on commit 092754c

Please sign in to comment.