Solved

ColdFusion Help displaying default value

Posted on 2012-03-17
6
305 Views
Last Modified: 2012-07-12
I'm searching a MySQL database using ColdFusion that has some empty fields within the database table. These empty fields display in an HTML table on the results page, as just being empty. What I'd like to do is to have the word "none" display if there is no value in the database for that field or column. In other words, I'd like to code my page to have the word "none" appear in place of those empty returns within my table.

Here is the search:
http://flashdesyne.com/wilsoncabinetry/search.cfm

Enter this model number: ET0444-O

Notice that the column for "Model Finish" is empty.

I'd like to have "none" appear in that column.

I tried cfparam with default as "none" but that didn't work.

Could someone please help me?

Thank you in advance.

elizabeth
0
Comment
Question by:Elizabeth2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:Elizabeth2
ID: 37733476
Thanks to some previous posts, I figured this out using:

<cfif NOT Len(Trim(myqueryname.model_finish))>
<cfset myqueryname.model_finish = "none">
</cfif>
0
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 37733548
good, u answered urself own

this way to

<cfif len(myqueryname.model_finish) IS 0>
None
</cfif>

No need to set and output it again

Cheers
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 37733554
This isn't correct..
<cfif NOT Len(Trim(myqueryname.model_finish))>
   <cfset myqueryname.model_finish = "none">
</cfif>

You cannot assign a value to a query column, although you could use the query set cell function.

<cfparam..> doesn't work because it does not test for empty, it tests for a non-existant variable...

Here's how you can do it..

In your select statement you can do this..

 select isNull(model_finihs,'none') as model_finish
       , ...
 from table...

Or when displaying you can use a CFIF statement..

<cfif Len(Trim(myqueryname.model_finish))>
   #myqueryname.model_finish#
<cfelse>
   none
</cfif>
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 7

Expert Comment

by:micropc1
ID: 37733793
You can do this in one line with IIF...

<cfoutput>
#IIF(LEN(TRIM(myqueryname.model_finish)), DE(myqueryname.model_finish), DE("none"))#
</cfoutput>

Open in new window

0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 37734207
btw using IIF will effect Performance of the page, So i will not recommend it
0
 
LVL 7

Expert Comment

by:micropc1
ID: 37734699
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question