?
Solved

<cfoutput>#getBureauProjects.bureauTitle#</cfoutput> does not display bureauTitle

Posted on 2014-11-03
11
Medium Priority
?
119 Views
Last Modified: 2014-11-03
ColdFusion 9

I have been staring at this for two hours. I could use some advice.

On this page: http://www.doivista.org/showBureauRecord.cfm?bureauID=9

I use <h2><cfoutput>#getBureauProjects.bureauTitle#</cfoutput> Projects, by State</h2> to display bureauTitle ... except the bureauTitle does not display.

Note: when a bureau has projects associated with it, the bureauTitle will display. If no projects, then ... no bureauTitle.

But I don't see the logic of that in the code.

Here are the query and the HTML. I am sure I am missing something quite obvious that I would see if I ever got more than five hours of sleep per night. =) Thanks for your help.

Query:

<cfquery name="getBureauProjects" datasource="#application.datasource#">
SELECT
b.bureauID,
b.bureauTitle,
p.projectID,
p.ProjectName,
p.bureauTitle,
p.State,
p.Archive
FROM #REQUEST.BureauTable# b
INNER JOIN #REQUEST.ProjectsTable# p
ON p.bureauTitle = b.bureauTitle
WHERE b.bureauID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(url.bureauID)#">
AND p.Archive = <cfqueryparam value="0" cfsqltype="cf_sql_bit">
ORDER BY p.State ASC
</cfquery>

Open in new window


HTML:

<h1><cfoutput>#REQUEST.companyName#</cfoutput> Projects</h1>


<h2><cfoutput>#getBureauProjects.bureauTitle#</cfoutput> Projects, by State</h2>


<cfif getBureauProjects.recordcount GT 0>

<cfoutput query="getBureauProjects" group="state">
<h3>#getBureauProjects.State#</h3>
<p><a href="/showProjectRecord.cfm?ProjectID=#val(getBureauProjects.ProjectID)#">#getBureauProjects.ProjectName#</a></p>
</cfoutput>

<cfelse>
<h2>Currently no projects are associated with this bureau. Please check back for future projects.</h2>

</cfif>

Open in new window

0
Comment
Question by:Eric Bourland
[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
  • 4
  • 4
  • 3
11 Comments
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 1000 total points
ID: 40420203
Basic stuff but are you sure the query is returning data?

If there are no projects ("Currently no projects are associated...") you won't see a bureauTitle...
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 1000 total points
ID: 40420207
EDIT: It's because the query uses an INNER JOIN. It only returns the title (and other fields) if there's one or more matching projects. As Sid pointed out, when there are no projects - the query will be empty. That's why you don't see the title.

If you always want to return the bureau title - even when there are no projects - use a LEFT JOIN.

<cfquery name="getBureauProjects" datasource="#application.datasource#">
SELECT
b.bureauID,
b.bureauTitle,
p.projectID,
p.ProjectName,
p.bureauTitle,
p.State,
p.Archive
FROM #REQUEST.BureauTable# b
            LEFT JOIN #REQUEST.ProjectsTable# p
            ON p.bureauTitle = b.bureauTitle
           <!--- no need for cfqueryparam when it's a hard coded value --->
           AND  p.Archive = 0
WHERE b.bureauID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(url.bureauID)#">
ORDER BY p.State ASC

Open in new window


However, changing the JOIN type means the recordCount will always be GT 0. You'll also need to change the CFIF logic

<!--- if a project was found ...--->
<cfif getBureauProjects.projectID GT 0>

<cfoutput query="getBureauProjects" group="state">
<h3>#getBureauProjects.State#</h3>
<p><a href="/showProjectRecord.cfm?ProjectID=#val(getBureauProjects.ProjectID)#">#getBureauProjects.ProjectName#</a></p>
</cfoutput>

<cfelse>
<h2>Currently no projects are associated with this bureau. Please check back for future projects.</h2>

</cfif>

Open in new window

0
 
LVL 36

Expert Comment

by:SidFishes
ID: 40420211
see agx posted exactly what I said...except with all that detail and stuff to help you actually solve the problem... :)
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 
LVL 52

Expert Comment

by:_agx_
ID: 40420220
I was so busy typing all that I didn't see your comment until after I posted :P  But once I did, I posted an "EDIT" to point that out ;-)
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 40420221
Sid, good to hear from you. Yes, I see now: in this case, the query does not return data.

Is there a way I can adjust that query so that the bureauTitle will display even if no projects are associated with the bureau?

Thanks for your help. =)

E
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 40420224
Got it now! Working on this. Thank you, _agx_ and Sid. More soon..... E
0
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 1000 total points
ID: 40420235
Eric PLEASE make sure you don't give me any points.  agx's answer is undoubtedly all you need...
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 1000 total points
ID: 40420257
No, he should because yours was the first response and it was right! You and GD always beat me out because I'm so overly wordy ;-)

Besides I am just teasing you because we both know we're not "those people" ie Ones that just repeat what was already said to get points.  Gotta love those folks ;-)
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 40420268
You're both awesome. It's working great. I am smiling big ... solving these problems and understanding the solution is the most sensible and logical part of my day.
0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 40420279
Thank you _agx_ and Sid. Ummm. I'm just gonna divvy up points, and, if either of you (or GD) ever make it to DC, let me cook dinner for you.

Hope your day is going great. =) Take care.

Eric

p.s. I'm reviewing in my Forta book the differences in the various kinds of JOINs. Good to remember this.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40420402
Thanks Eric!
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

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…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 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