title = "Add/Review Songleaders in the Songbook database" ; $page->name = "addsongleader"; $page->description=$page->title; include "./header.inc"; #echo "

Add a new songleader

"; $dummy = mysql_query( "set datestyle='European';"); $dummy = mysql_query("drop table s_songleader_distinct_songs;"); $dummy = mysql_query("create table s_songleader_distinct_songs (songleader int2, song_no int2);"); $dummy = mysql_query( "insert into s_songleader_distinct_songs select distinct ". "if(es.songleader,es.songleader,e.songleader) songleader_no, song_no ". "from s_event_song es, s_event e where e.event_no = es.event_no;"); $sl = mysql_query( "select sl.person, sl.name, count(es.song_no) from s_event e, s_event_song es, s_songleader sl where e.event_no = es.event_no and if(es.songleader,es.songleader,e.songleader) = sl.person group by sl.name, sl.person order by sl.name;"); $nsongleaders = mysql_NumRows($sl); echo << SongleaderTotal songs ledDifferent songs ledReuse percent EOM; for ($slrow = 0; $slrow < $nsongleaders; $slrow++) { $sltuple = mysql_fetch_row($sl); $sds = mysql_fetch_row(mysql_query( "select count(song_no) from s_songleader_distinct_songs where songleader = $sltuple[0];")); echo <<
$sltuple[1] $sltuple[2] $sds[0] EOM; echo number_format(100-$sds[0]*100/$sltuple[2]); echo "%\n"; } echo "\n"; $xml=true; include "./footer.inc"; echo ''; ?>