false]); http_response_code(422); exit; } $type = 'tr'; $data = include $baseDir . '/../scripts/db/db-verbindung-script.php'; if ($data['success'] === false){ echo json_encode(['success' => false, 'message' => $data['message']]); http_response_code(500); exit; } require $baseDir . '/../scripts/db/db-tables.php'; $musicId = intval($_POST['musicId']); $turnerinId = intval($_POST['turnerinId']); $sql = "UPDATE $tableTurnerinnen SET bodenmusik = ? WHERE id = ?"; $stmt = $mysqli->prepare($sql); $stmt->bind_param("ss", $musicId, $turnerinId); if (!$stmt->execute()) { http_response_code(500); exit; } $stmt->close(); $sql = "SELECT name, vorname FROM $tableTurnerinnen WHERE id = ?"; $stmt = $mysqli->prepare($sql); $stmt->bind_param("s", $turnerinId); if (!$stmt->execute()) { http_response_code(500); exit; } $result = $stmt->get_result(); $rows = $result->fetch_all(MYSQLI_ASSOC); $stmt->close(); $_SESSION['form_message_type'] = 1; if (!isset($rows) || !is_array($rows) || count($rows) !== 1) { $_SESSION['form_message'] = 'Musik aktualisiert'; } else { $_SESSION['form_message'] = 'Musik für '.$rows[0]['name'].' '.$rows[0]['vorname'].' aktualisiert'; } $mysqli->close(); echo json_encode(['success' => true]);