Ask a Question related to Coldfusion Database Access, Design and Development.
-
KimMazz #1
CFIF is being ignored
I have 2 cfif statements at the head of my doc that are being ignored in the
output. Only the efelse part of the statements are being read. I have
attached the code and I would really appreciate some insight as to why it's
being ignored.
In the first statement only the First part of the cfif is being output for
all instances. And the 2nd cfif statement only the last part is being output
for all instances.
Thanks,
Kim
Here is the recordset, and the cfif statements:
<cfquery name="rsGetEmployeeList" datasource="#request.dsn#">
SELECT yda_Employees.Emp_ID, yda_Employees.Emp_Role,
yda_Employees.Emp_FirstName, yda_Employees.Emp_LastName,
yda_ProgramsServices.Program_ID, yda_ProgramsServices.ProgramTitle,
yda_ProgramsServices.District
FROM yda_Employees INNER JOIN yda_ProgramsServices ON yda_Employees.Emp_ID =
yda_ProgramsServices.ProgramContact
GROUP BY yda_Employees.Emp_ID, yda_Employees.Emp_Role,
yda_Employees.Emp_FirstName, yda_Employees.Emp_LastName,
yda_ProgramsServices.Program_ID, yda_ProgramsServices.ProgramTitle,
yda_ProgramsServices.District
ORDER BY yda_Employees.Emp_ID ASC, yda_ProgramsServices.District DESC
</cfquery>
<!-- set the admin login level for each employee --->
<cfif isDefined("rsGetEmployeeList.Emp_Role") AND
rsGetEmployeeList.Emp_Role EQ 1>
<cfset EmployeeRole ="Administrator">
<cfelseif isDefined("rsGetEmployeeList.Emp_Role") AND
rsGetEmployeeList.Emp_Role EQ 2>
<cfset EmployeeRole ="Data Input Only">
<cfelse>
<cfset EmployeeRole ="No Level Assigned">
</cfif>
<!--- Set the School District for each program --->
<cfif isDefined("rsGetEmployeeList.District") AND
rsGetEmployeeList.District EQ 1>
<cfset SchoolDistrict = "Hrbrflds/Elwd">
<cfelseif isDefined("rsGetEmployeeList.District") AND
rsGetEmployeeList.District EQ 2>
<cfset SchoolDistrict = "Npt./E. Npt.">
<cfelse>
<cfif isDefined("rsGetEmployeeList.District") AND
rsGetEmployeeList.District EQ 3>
<cfset SchoolDistrict = "Both">
</cfif>
</cfif>
Here is the Query Output:
<table width="100%" border="0" cellpadding="3" cellspacing="10" id="border">
<tr>
<td colspan="3"><h5>Employees</h5></td>
</tr>
<cfoutput query="rsGetEmployeeList" Group="Emp_ID">
<tr>
<td>
<p>
#rsGetEmployeeList.Emp_FirstName#
#rsGetEmployeeList.Emp_LastName#<br>
Admin Level: #EmployeeRole# - #rsGetEmployeeList.Emp_Role#<br>
*** I output the role to see if it was being read correctly and it is
Programs Head:<br>
<cfoutput>#rsGetEmployeeList.ProgramTitle# - #SchoolDistrict#
(#rsGetEmployeeList.District#)<br></cfoutput> </td>
***The number in the parens is the district that should be converted to the
"ShcoolDistrict" variable.***
<td><a
href="InsertEmployee.cfm?EmployeeID=#rsGetEmployee List.Emp_ID#">Edit</a></td>
<td><a
href="DeleteEmployee.cfm?EmployeeID=#rsGetEmployee List.Emp_ID#">Delete</a></td>
</tr>
</cfoutput>
</table>
Here is the actual HTML that is viewed in the browser. See the numbers are
correct, but the variable ShcoolDistrict is being read as "both" no matter
what the corresponding number is. And, the Admin Level is being set to
Administrator even for someone with the level of "2".
Rod Miller
Admin Level : Administrator - 1
Programs Head:
Individual Counseling - Both (3)
Max Burns
Admin Level : Administrator - 2 **** Should be set to Data Input Only
Programs Head:
NMS YDA Afterschool - Both (2)
Shannon Killeen
Admin Level : Administrator - *** Should show No Level Assigned
Programs Head:
International Cooking - Both (3)
ENMS YDA After School - Both (2) *** Should show Npt./E. Npt.
Northport Youth Council - Both (2)
Grandfriends - Both (2)
Girls Only - Both (2)
Northport High School Drop-In - Both (1) *** Should be set to Hrbrflds/Elwd
Northport Middle School Drop In - Both (1)
KimMazz Guest
-
CFIF help
I have an HTML that has a list of names pulled from a Database. In my HTML table my headers are Read, Write, Release, View For each employee that... -
CFIF Big Problem
hi All, ok I?ma beginnner with CF. Maybe this sounds ridiculous but by me the" if" condition of Coldfusion don?t work. System: XP , Editor:... -
Use of CFIF with in a CFSWITCH
Is it possible to use a cfif statement with in a cfswitch statement. below is an example: <cfswitch expression="#var1#"> <cfcase>some... -
problem with cfif
Hello all as you the codes I've written you will notice that all of the <cfif> and </cfif> are pairs but I have been recieved this error: Context... -
cfif being ignored
I wanted this to only execute if FORM.rp_image does not = defaultImg.gif but it seems to always run. I thought the syntax was okay but maybe not. ... -
JMGibson3 #2
Re: CFIF is being ignored
You need to get all those cfifs down inside the <cfoutput query=> loop.
Standalone at the top as you have them now, CF does them only once using only
the first row.
Also, what was the intent of the IsDefined? A better way to do that is <cfif
rsGetEmployeeList.RecordCount GT 0>. If the query returned any rows at all,
all columns are IsDefined otherwise all columns are NOT IsDefined. However, if
everything is down in the <cfoutput loop you don't even need that. If there
are no rows returned it's bypassed, so you might want to precede the <cfouput>
with a <cfif rsGetEmployeeList.RecordCount EQ 0><p>No Employees Found<cfelse>
JMGibson3 Guest
-
KimMazz #3
Re: CFIF is being ignored
JMGibson3
Thanks for the help. I thought all the processing code had to be at the top
of a page. When I moved it in to the query output then it worked.
And, as for the intent of the IsDefined. Is that in reading the WACK book I
thought it said to always check to make sure a variable exists. So, I
thought it correct to check to make sure the value was defined before
setting the variable.
I can't check for a record count, because there will always be employees,
but each employee may or may not have a district or login set for them.
Kim
"JMGibson3" <webforumsuser@macromedia.com> wrote in message
news:dvmu1f$oou$1@forums.macromedia.com...> You need to get all those cfifs down inside the <cfoutput query=> loop.
> Standalone at the top as you have them now, CF does them only once using
> only
> the first row.
>
> Also, what was the intent of the IsDefined? A better way to do that is
> <cfif
> rsGetEmployeeList.RecordCount GT 0>. If the query returned any rows at
> all,
> all columns are IsDefined otherwise all columns are NOT IsDefined.
> However, if
> everything is down in the <cfoutput loop you don't even need that. If
> there
> are no rows returned it's bypassed, so you might want to precede the
> <cfouput>
> with a <cfif rsGetEmployeeList.RecordCount EQ 0><p>No Employees
> Found<cfelse>
>
KimMazz Guest
-
JMGibson3 #4
Re: CFIF is being ignored
You don't really have to check if a variable exists if you KNOW it exists. Of
course if you only thought it exists your users may be looking at error pages
every once in awhile. That's probably the reason behind the WACK suggestion,
but it sure makes for a lot more coding. I never do, unless there's a chance
it doesn't exist: timed out session variables, Form variables, pages running
with or without URL parms, etc.
JMGibson3 Guest



Reply With Quote

