<?php
require_once __DIR__ . '/../includes/db.php';
$data = json_decode(file_get_contents('php://input'), true);

$fieldId = (int)$data['field_id'];
$index   = (int)$data['index'];

$stmt = $pdo->prepare("SELECT values_json FROM bol_value_presets WHERE field_id=?");
$stmt->execute([$fieldId]);
$values = json_decode($stmt->fetchColumn(), true);

array_splice($values, $index, 1);

$stmt = $pdo->prepare("
UPDATE bol_value_presets
SET values_json=?
WHERE field_id=?
");

$stmt->execute([json_encode($values),$fieldId]);
