How can I prevent empty query values from creating empty table cells?

If you place the contents of a ColdFusion query in an HTML table, any blank query value may show up as an empty cell with no borders in the table. This is not a bug in ColdFusion, but rather a result of how the browser renders the a cell that looks like this:

<td></td>

To prevent this, you can check for an empty value and display a non-breaking space instead:

<td>
<cfif theValue is "">&nbsp;<cfelse>#theValue#</cfif>
</td>

This question was written by Raymond Camden
It was last updated on May 23, 2006.

Categories

Strings

Comments

comments powered by Disqus