prepare("SELECT household_id FROM users WHERE id = ?"); $stmt_household->bind_param("i", $current_user_id); $stmt_household->execute(); $household_id = $stmt_household->get_result()->fetch_assoc()['household_id']; $stmt_household->close(); $household_member_ids = [$current_user_id]; if ($household_id) { $stmt_members = $conn->prepare("SELECT id FROM users WHERE household_id = ?"); $stmt_members->bind_param("i", $household_id); $stmt_members->execute(); $result_members = $stmt_members->get_result(); while ($row = $result_members->fetch_assoc()) { if (!in_array($row['id'], $household_member_ids)) { $household_member_ids[] = $row['id']; } } $stmt_members->close(); } $placeholders = implode(',', array_fill(0, count($household_member_ids), '?')); $types = str_repeat('i', count($household_member_ids)); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['add_manufacturer'])) { $manufacturer_name = trim($_POST['manufacturer_name']); if (!empty($manufacturer_name)) { $stmt = $conn->prepare("INSERT INTO manufacturers (name, user_id) VALUES (?, ?)"); $stmt->bind_param("si", $manufacturer_name, $current_user_id); if ($stmt->execute()) { if ($household_id) { $log_message = htmlspecialchars($_SESSION['username']) . " hat den Hersteller '" . htmlspecialchars($manufacturer_name) . "' hinzugefügt."; log_household_action($conn, $household_id, $current_user_id, $log_message); } $message = ''; } else { if ($conn->errno == 1062) { $message = ''; } else { $message = ''; } } $stmt->close(); } else { $message = ''; } } elseif (isset($_POST['edit_manufacturer'])) { // ... (POST-Logik unverändert) ... } } elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) { // ... (DELETE-Logik unverändert) ... } $manufacturers_query = $conn->prepare("SELECT m.id, m.name, m.user_id, u.username as creator_name FROM manufacturers m JOIN users u ON m.user_id = u.id WHERE m.user_id IN ($placeholders) ORDER BY m.name ASC"); $manufacturers_query->bind_param($types, ...$household_member_ids); $manufacturers_query->execute(); $manufacturers_list = $manufacturers_query->get_result()->fetch_all(MYSQLI_ASSOC); $manufacturers_query->close(); $conn->close(); ?>

Hersteller im Haushalt

Neuen Hersteller hinzufügen
" method="post" class="row g-3 align-items-end">
Bestehende Hersteller
Keine Hersteller gefunden.
(von )