Question
Updating db via Form
Currently we have 1 person updating staff profiles from our
company. Recently they asked me to add a new field titled: Global
Public Health Experience. Basically I added the section and radio
buttons indicating a Yes or No answer. Everything on that page is
saved onto a MySQL database, which I respectively also created a
new section for the new field.
Once I did everything and ran a test I realized it was reading the database fine but not updating it if the answer changed from Yes to No or vice-versa. I changed the answer in the database itself and it updated perfectly but when i try to update it via the form, event though I don't get any error messages, it doesn't apply the updates onto the database.
Here's everything I have.
First I run the SQL query that updates database (what you see in bold is the section for this new field):
<cfquery name="bioupdate" datasource="sph_Edit">
UPDATE tblpersonnel
SET tblPers_gphe='#gphe#'
WHERE tblPers_ID_pk='#URL.tblPers_ID_pk#'
</cfquery>
Then I have a query reading the database (the bold is for the new field):
<cfquery name="bio" datasource="sph_Read">
SELECT * from tblpersonnel WHERE tblPers_ID_pk='#URL.tblPers_ID_pk#'
</cfquery>
<!-- Set Paramaters -->
<cfset bioStruct=StructNew()>
<cfset bioStruct.gpheY="no" >
<cfset bioStruct.gpheN="no" >
Then I created conditions to select the correct answer on the form:
<cfif #bio.tblPers_gphe# EQ 'y'>
<cfset bioStruct.gpheY="yes">
<cfelse>
<cfset bioStruct.gpheN="yes">
</cfif>
Finally here's the field itself (nothing bold here, it's all for the new field):
<div class="inputtitlelong">Global Public Health Experience</div>
<div align="center" class="htmlinputlong2" id="gphexperience">
<cfinput name="gphe" type="radio" required="yes" message="Please indicate if this member has Global Public Health Experience" value="y" checked="#bioStruct.gpheY#" />Yes
<cfinput name="gphe" type="radio" value="n" checked="#bioStruct.gpheN#" />No
</div>
Please, if you notice something's wrong let me know. I've been struggling with this issue for some time now and still can't figure out what the heck is causing it not to work. Thanks for all your help in advance!
Once I did everything and ran a test I realized it was reading the database fine but not updating it if the answer changed from Yes to No or vice-versa. I changed the answer in the database itself and it updated perfectly but when i try to update it via the form, event though I don't get any error messages, it doesn't apply the updates onto the database.
Here's everything I have.
First I run the SQL query that updates database (what you see in bold is the section for this new field):
<cfquery name="bioupdate" datasource="sph_Edit">
UPDATE tblpersonnel
SET tblPers_gphe='#gphe#'
WHERE tblPers_ID_pk='#URL.tblPers_ID_pk#'
</cfquery>
Then I have a query reading the database (the bold is for the new field):
<cfquery name="bio" datasource="sph_Read">
SELECT * from tblpersonnel WHERE tblPers_ID_pk='#URL.tblPers_ID_pk#'
</cfquery>
<!-- Set Paramaters -->
<cfset bioStruct=StructNew()>
<cfset bioStruct.gpheY="no" >
<cfset bioStruct.gpheN="no" >
Then I created conditions to select the correct answer on the form:
<cfif #bio.tblPers_gphe# EQ 'y'>
<cfset bioStruct.gpheY="yes">
<cfelse>
<cfset bioStruct.gpheN="yes">
</cfif>
Finally here's the field itself (nothing bold here, it's all for the new field):
<div class="inputtitlelong">Global Public Health Experience</div>
<div align="center" class="htmlinputlong2" id="gphexperience">
<cfinput name="gphe" type="radio" required="yes" message="Please indicate if this member has Global Public Health Experience" value="y" checked="#bioStruct.gpheY#" />Yes
<cfinput name="gphe" type="radio" value="n" checked="#bioStruct.gpheN#" />No
</div>
Please, if you notice something's wrong let me know. I've been struggling with this issue for some time now and still can't figure out what the heck is causing it not to work. Thanks for all your help in advance!
