Countdown timer

I recently found myself in need of a countdown timer. Out of laziness I Googled around a bit but found nothing I wanted to use so I relented and threw this together. Enter a number of seconds and the countdown timer will count down to zero from that time. Download the source here.


Output ColdFusion Query Results to XML

I don’t claim to be a ColdFusion expert by any stretch of the imagination, but recently I found myself in need of coming up with a way to output query results to an XML file. My example below is based on an absolutely hideous article I stumbled across on the ColdFusion Developer Center. The example they provide has several errors in syntax: unclosed tags, unclosed quotes, unOPENED pounds, etc. It also only outputs one record!

After about an hour of playing with it I was able to get the code working properly and I thought I’d share a very basic example. The following code queries a database for names and phone numbers then outputs them all to a file name phonelist.xml in the current path:

<cfquery name="qGetPhoneList" datasource="datasource">
select first_name,last_name,phone from employees

<!—Create a temporary variable "tempxml" to hold our XML document—>

<cfset tempxml = "<?xml version =""1.0""?>
<!DOCTYPE phonelist [
<!ELEMENT phonelist (firstname,lastname,phone)>
<cfloop query="qGetPhoneList">
<cfset tempxml = "#tempxml#
<cfset tempxml = "

<!—show the XML in the HTML output —>
<P>This is a simple XML document that’s been generated by the ColdFusion code. </P>

<!—write out the XML—>
<cfset writePath=#ExpandPath("phonelist.xml")#>
#writePath#<br />
<cffile action = "Write" file="#writePath#" output="#tempxml#">