-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeleteB.php
More file actions
36 lines (27 loc) · 1.15 KB
/
deleteB.php
File metadata and controls
36 lines (27 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
error_reporting(E_ALL);
ini_set("display errors", 1);
require "database.php";
$db = new Database();
$bill_id = $_POST['bill_id'];
$stmt = $db->prepare("SELECT * FROM payees WHERE bill_id=:bill_id;");
$stmt->bindValue(':bill_id',$bill_id, SQLITE3_INTEGER);
$payees = $stmt->execute();
$stmt = $db->prepare("SELECT * FROM bills WHERE bill_id=:bill_id;");
$stmt->bindValue(':bill_id',$bill_id, SQLITE3_INTEGER);
$bills = $stmt->execute();
$bill = $bills->fetchArray();
$stmt = $db->prepare("SELECT * FROM groups WHERE group_id=:group_id;");
$stmt->bindValue(':bill_id',$bill['group_id'], SQLITE3_INTEGER);
$groups = $stmt->execute();
$group = $bills->fetchArray();
while(($payee = $payees->fetchArray())) {
$db->query("INSERT INTO notifs VALUES(NULL,".$payee['user_id'].",'Bill ".$bill['bill_id']." has been deleted from group ".$group['name']."');");
}
$stmt = $db->prepare("DELETE FROM payees WHERE bill_id=:bill_id;");
$stmt->bindValue(':bill_id',$bill_id, SQLITE3_INTEGER);
$stmt->execute();
$stmt = $db->prepare("DELETE FROM bills WHERE bill_id=:bill_id;");
$stmt->bindValue(':bill_id',$bill_id, SQLITE3_INTEGER);
$stmt->execute();
?>