pmayadun 0 Newbie Poster

Hi all, can someone help? I have been trying to figure out how to put together an update page. For some reason it is not working.
I have been trying to figure this out for about a week and a half. I am sure it will be something very easy for you but finally I have decided to ask for some help. Is it a looping problem or is there an easier way to do this?

OK a bit of background: It is the same three tables as before...(ACCESS tables which I will have to convert for the MYSQL).

1. gradschoolsabroad (has the field GradschoolsAbroadID and others)
2. AreasOfStudy (has the filds AreaOfStudy and AreaOfStudyID)
3. Gradschoolsabroad_AreaOfStudy (has the fields GradschoolsAbroadID and AreasOfStudyID and this table is LINKED to the two above. It is linked via GradschoolsAbroadID and AreasOfStudyID to tables 1 and 2 above).

It is to THIS table 'Gradschoolsabroad_AreaOfStudy' that I am trying to INSERT and UPDATE ). The UPDATE from has amongst other elements, a series of check boxes that correpond to their respective AreaOfStudyID.
The user is selected via their GradschoolsAbroadID (via SESSION ID).

The problem is that when the update form is displayed it only displayes which ever is the FIRST one of the AreasOfStudy elements that is checked. It simply does not display the others.

The CF code is as follows:

<cfparam name="FORM.AreaOfStudyID" default="1">
<cfparam name="SESSION.Auth.GradschoolsAbroadProgramID" default="">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form1">
<cfloop query="areaofstudy">
<cfquery datasource="studyabroad">
UPDATE Gradschoolsabroad_AreaOfStudy SET GradschoolsAbroadProgramID=
<cfif IsDefined("FORM.GradschoolsAbroadProgramID") AND #FORM.GradschoolsAbroadProgramID# NEQ "">
#FORM.GradschoolsAbroadProgramID#
<cfelse>
NULL
</cfif>
, AreaOfStudyID=
<cfif IsDefined(#gradarea.AreaOfStudyID#)>
Yes
<cfelse>
No
</cfif>
WHERE AreaOfStudyID=#FORM.AreaOfStudyID#
</cfquery>
</cfloop>
<cflocation url="sample.htm">
</cfif>
<cfquery name="areaofstudy" datasource="studyabroad">
SELECT * FROM AreaOfStudy
</cfquery>
<cfquery name="gradID" datasource="studyabroad">
SELECT * FROM gradschoolsabroad WHERE GradschoolsAbroadProgramID = #SESSION.Auth.GradschoolsAbroadProgramID#
</cfquery>
<cfquery name="gradarea" datasource="studyabroad">
SELECT * FROM Gradschoolsabroad_AreaOfStudy WHERE GradschoolsAbroadProgramID = #SESSION.Auth.GradschoolsAbroadProgramID# ORDER BY AreaOfStudyID ASC
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" name="form1" action="<cfoutput>#CurrentPage#</cfoutput>">
<table align="center">
<cfoutput query="areaofstudy">
<tr valign="baseline">
<td nowrap align="right">#areaofstudy.AreaOfStudy#</td>
<td><input type="checkbox" name="AreaOfStudyID" value="#AreaOfStudyID#" <cfif (#gradarea.AreaOfStudyID# EQ #areaofstudy.AreaOfStudyID#)>checked</cfif>></td>
</tr>
</cfoutput>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="GradschoolsAbroadProgramID" value="<cfoutput>#gradarea.GradschoolsAbroadProgramID#</cfoutput>">
<input type="hidden" name="MM_UpdateRecord" value="form1">
<input type="hidden" name="ID" value="<cfoutput>#gradarea.ID#</cfoutput>">
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.