Silver79 Fresher
Joined: 02 Dec 2006 Posts: 11 Location: Detroit, MI
|
Posted: Sun Dec 03, 2006 10:35 pm Post subject: cfloop help |
|
|
I would like to display all the programs in a select box and only select the ones that are coming from the database (the user's saved programs).
Code:
<cfquery>
SELECT F.ID, F.First_Name, F.Last_Name, F.a, F.b, F.c, F.d
FROM Table1 F
WHERE F.Id = <cfqueryparam>
</cfquery>
<form>
<cfoutput>
<p>First Name*<br><input></p>
<p>Last Name*<br><input></p>
...
MORE FIELDS
...
|
<cfquery>
SELECT FATP.table2ID, FATP.ProgramID as FATPPID, t3.Name as t3Name
FROM table2 FATP INNER JOIN table3 t3 ON FATP.ProgramID = t3.ProgramID
WHERE FATP.table2ID = #URL.myID#
</cfquery>
<cfquery>
SELECT ProgramID, Name FROM table3
</cfquery>
<select>
<option>Please Select</option> <cfloop>
<option value="#ProgramID#" <cfif>selected</cfif>>#Name#</option>
</cfloop>
</select>
|
|
</cfoutput>
</form>
How can I correct this looping problem? |
|
cindy Member
Joined: 02 Dec 2006 Posts: 22
|
Posted: Sun Dec 03, 2006 10:35 pm Post subject: |
|
|
Create a list of all programid's from query2 and then do a listfind on that list against the query3's programid.
EX Code:
<cfquery>
SELECT FATP.table2ID, FATP.ProgramID as FATPPID, t3.Name as t3Name
FROM table2 FATP INNER JOIN table3 t3 ON FATP.ProgramID = t3.ProgramID
WHERE FATP.table2ID = #URL.myID#
</cfquery>
<cfset>
<cfquery>
SELECT ProgramID, Name FROM table3
</cfquery>
<select>
<option>Please Select</option>
<cfloop>
<option value="#ProgramID#" <cfif>selected</cfif>>#Name#</option>
</cfloop>
</select> |
|