';
}
else {
$stmt = $mysqli->prepare("SELECT TRUE FROM ImgAnnotations WHERE id = ? LIMIT 1");
$stmt->bind_param("i", $_POST["TheID"]);
$stmt->execute();
$result = $stmt->get_result(); // get the mysqli result
if( mysqli_num_rows($result) > 0) {
//ID does exits, updating";
$stmt = $mysqli->prepare("UPDATE ImgAnnotations SET data = ? WHERE id = ?");
$stmt->bind_param("si", $_POST["TheNewData"], $_POST["TheID"]);
}else {
//ID doesn't exits, creating";
$stmt = $mysqli->prepare("INSERT INTO ImgAnnotations (id, data) VALUES (?, ?)");
$stmt->bind_param("is", $_POST["TheID"], $_POST["TheNewData"]);
}
$stmt->execute();
echo 'Data has been saved
Editor Viewer';
}
?>