prepare("INSERT INTO songs (name, artist, bpm, song_key, duration_seconds, notes, tags) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$name, $artist, $bpm, $song_key, $duration_seconds, $notes, $tags]); $_SESSION['notification'] = ['message' => 'השיר נוצר בהצלחה!', 'type' => 'success']; } else { // update $id = (int)($_POST['id'] ?? 0); if ($id > 0) { $stmt = $pdo->prepare("UPDATE songs SET name=?, artist=?, bpm=?, song_key=?, duration_seconds=?, notes=?, tags=? WHERE id=?"); $stmt->execute([$name, $artist, $bpm, $song_key, $duration_seconds, $notes, $tags, $id]); $_SESSION['notification'] = ['message' => 'השיר עודכן בהצלחה!', 'type' => 'success']; } } } elseif ($action === 'delete') { $id = (int)($_POST['id'] ?? 0); if ($id > 0) { $stmt = $pdo->prepare("DELETE FROM songs WHERE id=?"); $stmt->execute([$id]); $_SESSION['notification'] = ['message' => 'השיר נמחק בהצלחה.', 'type' => 'danger']; } } } catch (Exception $e) { $_SESSION['notification'] = ['message' => 'אירעה שגיאה: ' . $e->getMessage(), 'type' => 'danger']; } // Redirect to avoid form resubmission header("Location: songs.php"); exit(); } // Check for notification from session if (isset($_SESSION['notification'])) { $notification = $_SESSION['notification']; unset($_SESSION['notification']); } // Fetch songs with search functionality $search = $_GET['search'] ?? ''; $sql = "SELECT * FROM songs"; $params = []; if (!empty($search)) { $sql .= " WHERE name LIKE ? OR artist LIKE ? OR bpm LIKE ? OR song_key LIKE ? OR notes LIKE ? OR tags LIKE ?"; $searchTerm = "%{$search}%"; $params = [$searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm]; } $sql .= " ORDER BY id ASC"; $stmt = $pdo->prepare($sql); $stmt->execute($params); $songs = $stmt->fetchAll(); function format_duration($seconds) { if ($seconds === null || $seconds < 0) return '00:00'; $mins = floor($seconds / 60); $secs = $seconds % 60; return sprintf('%02d:%02d', $mins, $secs); } // --- Presentation --- include 'includes/header.php'; ?>

מאגר השירים

$song): ?>
# שם האמן שם השיר BPM סולם משך תגים הערות פעולות
לא נמצאו שירים התואמים את החיפוש "". עדיין אין שירים במאגר. הוסף את השיר הראשון שלך!