-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_annotation.php
47 lines (41 loc) · 1.49 KB
/
update_annotation.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$connection = pg_connect("host=localhost port=5432 dbname=bridges user=postgres password=root");
if (!$connection) {
echo "An error occurred.<br>";
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST["id"];
$newTitle = $_POST["newTitle"];
$newDescription = $_POST["newDescription"];
$newPosition = $_POST["newPositionArray"];
$camPosition = $_POST["camPositionArray"];
$camTarget = $_POST["camTargetArray"];
$typology = $_POST["typology"];
// Update data in the annotations table
$query = "UPDATE annotations SET
title = '$newTitle',
description = '$newDescription',
pos_x = " . explode(',', $newPosition)[0] . ",
pos_y = " . explode(',', $newPosition)[1] . ",
pos_z = " . explode(',', $newPosition)[2] . ",
campos_x = " . explode(',', $camPosition)[0] . ",
campos_y = " . explode(',', $camPosition)[1] . ",
campos_z = " . explode(',', $camPosition)[2] . ",
tarpos_x = " . explode(',', $camTarget)[0] . ",
tarpos_y = " . explode(',', $camTarget)[1] . ",
tarpos_z = " . explode(',', $camTarget)[2] . ",
typology = '$typology'
WHERE id = $id";
$result = pg_query($connection, $query);
if (!$result) {
echo "Error inserting data: " . pg_last_error($connection);
} else {
// Fetch the inserted ID and echo it in the response
$insertedRow = pg_fetch_assoc($result);
$insertedId = $insertedRow['id'];
echo $insertedId;
}
}
pg_close($connection);
?>