-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteeqscript.php
32 lines (25 loc) · 931 Bytes
/
deleteeqscript.php
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
<?php
include 'db_connect.php';
$del_eq = $_POST['del_eq'];
//Delete all calendar layers
$sql = "DELETE FROM webcal_user_layers WHERE cal_layeruser = '".$del_eq."'";
$conn_webcam->query($sql);
$sql = "DELETE FROM webcal_user_layers WHERE cal_login = '".$del_eq."'";
$conn_webcam->query($sql);
//Find all the users of equip.
$sql = 'SELECT Name FROM '.$del_eq;
$result = $conn_equipt->query($sql);
foreach($result as $value){
//Delete eq from each table.
$sql_eq = 'DELETE FROM '.$value['Name'].' WHERE Equipment_Name = "'.$del_eq.'"';
echo $sql_eq.'<br>';
$conn_users->query($sql_eq);
}
//Now delete equipment from main table and drop individual table.
$sql_us = 'DELETE FROM EQ_LIST WHERE abbrev = "'.$del_eq.'"';
$conn_equipt->query($sql_us);
$sql_us = 'DROP TABLE '.$del_eq;
$conn_equipt->query($sql_us);
$conn_webcam->query("DELETE FROM webcal_user WHERE cal_login = '$del_eq'");
header("location:allequip.php");
?>