54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
#include_once("inc/db_connect.php");
|
|
|
|
$conn = new PDO('sqlite:../db_photo.sqlite3');
|
|
//$stmt = $conn->prepare($query);
|
|
//$stmt->execute();
|
|
|
|
include 'functions.php';
|
|
|
|
_pr($_POST);
|
|
// lens legende copyright title creator keywords
|
|
|
|
if ($_POST['action'] == 'edit' && $_POST['id']) {
|
|
$updateField='';
|
|
if(isset($_POST['lens'])) {
|
|
$updateField.= "lens='".$_POST['lens']."'";
|
|
} else if(isset($_POST['legende'])) {
|
|
$updateField.= "legende='".$_POST['legende']."'";
|
|
} else if(isset($_POST['copyright'])) {
|
|
$updateField.= "copyright='".$_POST['copyright']."'";
|
|
} else if(isset($_POST['title'])) {
|
|
$updateField.= "title='".$_POST['title']."'";
|
|
} else if(isset($_POST['creator'])) {
|
|
$updateField.= "creator='".$_POST['creator']."'";
|
|
} else if(isset($_POST['keywords'])) {
|
|
$updateField.= "keywords='".$_POST['keywords']."'";
|
|
}
|
|
if($updateField && $_POST['id']) {
|
|
$sqlQuery = "UPDATE photos SET $updateField WHERE id='" . $_POST['id'] . "'";
|
|
echo $sqlQuery;
|
|
/*
|
|
mysqli_query($conn, $sqlQuery) or die("database error:". mysqli_error($conn));
|
|
$data = array(
|
|
"message" => "Record Updated",
|
|
"status" => 1
|
|
);
|
|
echo json_encode($data);
|
|
*/
|
|
}
|
|
}
|
|
if ($_POST['action'] == 'delete' && $_POST['id']) {
|
|
$sqlQuery = "DELETE FROM photos WHERE id='" . $_POST['id'] . "'";
|
|
echo $sqlQuery;
|
|
/*
|
|
mysqli_query($conn, $sqlQuery) or die("database error:". mysqli_error($conn));
|
|
$data = array(
|
|
"message" => "Record Deleted",
|
|
"status" => 1
|
|
);
|
|
echo json_encode($data);
|
|
*/
|
|
}
|
|
|