Songs
$chosen_by = mysql_real_escape_string($_GET["chosen_by"]);
$title_pattern = mysql_real_escape_string($_POST["title_pattern"]);
$performance_date = mysql_real_escape_string($_GET["performance_date"]);
if ( $title_pattern <> "") {
echo " containing \"$title_pattern\"";
}
if ( $chosen_by <> "") {
echo " chosen by \"$chosen_by\"";
$query="SELECT Title, source, songs.song_id, DATE_FORMAT(date, '%D %b %Y') FROM songs INNER JOIN performance where Title like '%$title_pattern%' and performance.chooser = '$chosen_by' and songs.song_id = performance.song_id order by Title";
$date_header = "Date sung";
##$date_header = "Last sung";
} else if ($performance_date <> "") {
# Date in a more readable format
echo " used on ", date("l, jS F Y", strtotime($performance_date));
$query="SELECT Title, source, songs.song_id, DATE_FORMAT(date_last_performed, '%D %b %Y'), date FROM songs INNER JOIN performance where Title like '%$title_pattern%' and performance.date = '$performance_date' and songs.song_id = performance.song_id order by performance.date";
# We show the date last performed as we already know the date of the performance we're interested in - it's at the top of the page.
$date_header = "Date last used";
} else {
$query="SELECT Title, source, song_id, DATE_FORMAT(date_last_performed, '%D %b %Y') FROM songs where Title like '%$title_pattern%' order by date_last_performed desc";
$date_header = "Date last used";
}
?>
Title
Source
# Header depends on whether the column is "Date last used" or "Date of performance"
echo $date_header;
?>