From d62207327c99ea070985d46eaa8399b139914a86 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Wed, 20 Dec 2006 02:59:31 +0000 Subject: * Added new icons, and speed up icon display * Fixed ORDER BY `track` on play selected * Started work on editing/flagging albums and artists --- lib/song.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/song.php') diff --git a/lib/song.php b/lib/song.php index b1d3579d..8aa24ead 100644 --- a/lib/song.php +++ b/lib/song.php @@ -44,6 +44,39 @@ function get_songs($sql, $action=0) { } // get_songs +/** + * get_songs_from_type + * This gets an array of songs based on the type and from the results array + * can pull songs from an array of albums, artists whatever + */ +function get_songs_from_type($type,$results,$artist_id='') { + + // Init the array + $songs = array(); + + $type = sql_escape($type); + + $sql = "SELECT id FROM song WHERE "; + + foreach ($results as $value) { + $value = sql_escape($value); + $sql .= "`$type`='$value' OR "; + } + + // Run the long query + $sql = rtrim($sql,'OR '); + $sql .= " ORDER BY `track`"; + + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $songs[] = $r['id']; + } + + return $songs; + +} // get_song_from_type + /** * get_recently_played * This function returns the last X songs that have been played -- cgit