Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO AVOID EMPTY CELLS

Status
Not open for further replies.

alexfusion

Programmer
Feb 5, 2001
94
0
0
AR
Hello Everybody,
This is my question:
I have a result page in CF that retrieve information from a database,displaying the results in a HTML table.(the HTML table has a border).
The problem is that sometimes there may be a table field empty,and the table cell that shows the content looks with no borders.You know what I mean.Ugly.
I need to check if the table field is empty so the page write   code to avoid the bad look.
How can I loop beetwen the table rows and columns to check if there is an empty field?
I tried with QUERY LOOP but I don't know how to acces the content of the columns.Do I have to specify the name of each field?.I've 40 !
Any help very much appreciated.

Thank you so much.

alexfusion

mixale@hotmail.com
 
you can try to work with table rows in the way where you will include the whole row in you IF decision, e.g.:

instead:

<tr>
<td>
<cfif queryName.RecordCount GT 0>
<cfoutput>testing</cfoutput>
</cfif>
</td>
</tr>

try:

<cfif queryName.RecordCount GT 0>
<cfoutput>
<tr>
<td>
testing
</td>
</tr>
</cfoutput>
</cfif>

this way, if query returns no results, the whole row will be skipped and should not mess up the table lay out; in the same manner you can work with table cells, or if you need to have table cell, but query might return no records, you can try something like this:

<tr>
<td>
<cfif queryName.RecordCount GT 0>
<cfoutput>testing</cfoutput>
<cfelse>
&nbsp;
</cfif>
</td>
</tr> Sylvano
dsylvano@hotmail.com

&quot;every and each day when I learn something new is a small victory...&quot;
 
If you just want to get around empty cells but leave the whole row, you could check each one and do
Code:
<cfif myQuery.fieldName IS NOT &quot;&quot;>
    #myQuery.fieldName#
<cfelse>
     &nbsp;
</cfif>
Or you could cheat a little if it doesn't mess up your formatting too much:
Code:
#myQuery.fieldName#&nbsp;
Yes, every field would have a space after the data, but some tables still look fine with that. It's quick and simple, though it would still be best to check each one by name, I'd think.

Good luck!
 
I think Glowball meant to show you this, but it didn't show up.

#myQuery.fieldName#&nbsp;

I would do that solution or this:
<CFIF Len(Trim(myQuery.fieldName))>
#myQuery.fieldName#
<CFELSE>
&nbsp;
</CFIF> - tleish
 
I swear I checked before posting, the non-breaking space entity thing is not showing up. I even put in the entity for ampersand and then nbsp; but it still didn't do it. Sheesh.
 
Take the easy way out... in any cell that MAY have a blank or null, put in a &nbsp; for non-blanking space! Works great!
 
Glowball, it's looks like you're not the only one, I checked mine before I posted it and it showed up in the preview... but not here. Let's try it again:

#myQuery.fieldName# & nbsp;

or

I would do that solution or this:
<CFIF Len(Trim(myQuery.fieldName))>
#myQuery.fieldName#
<CFELSE>
& nbsp;
</CFIF> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top