Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ColdFusion Help displaying default value

Posted on 2012-03-17
6
Medium Priority
?
306 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 2000 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
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 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