Last year I did a few Christmas style friday challenges, so I’m a bit overdue. This one is rather simple. Given a query that contains an ID, which corresponds to a day, and a gift, print out the famous “12 Days of Christmas” song dynamically. Ie, day 1 you get gift 1. Day 2 you get 1 of gift 1, and 2 of gift 2. And so on.
Bonus points if you use festive green and red fonts in your display. (Once again, this is why they don’t let me design.)
Double bonus points if you make a cfpresentation out it and record MP3s to go along with it.
Here is your query that you must use with the code. (Note, it uses CF8 Array shorthand style. If you aren’t on CF8, you can rewrite that as a list and use listToArray.)
<cfset song = querynew("id,gift","integer,varchar")>
<cfset gifts = [“A partridge in a pear tree”,”Two turtle doves”,”Three French hens”,”Four calling birds”,”Five golden rings”,”Six geese a-laying”, “Seven swans a-swimming”,”Eight maids a-milking”,”Nine ladies dancing”,”Ten lords a-leaping”,”Eleven pipers piping”,”Twelve drummers drumming”]>
<cfloop index=”x” from=”1” to=”#arrayLen(gifts)#”> <cfset queryAddRow(song)> <cfset querySetCell(song, “id”, x)> <cfset querySetCell(song, “gift”, gifts[x])> </cfloop> </code>