troubleshooting Question

changing name in data base

Avatar of HawaiiDragon
HawaiiDragon asked on
HTMLAdobe DreamweaverMySQL Server
1 Comment1 Solution297 ViewsLast Modified:
Hi all, I am new to coding in Coldfusion and  MYSQL so used to C# and Microsoft SQL  that I am having rookie problems. LOL Anyway here is the situation.

I have created a online timecard app. The employee names are populated in the dropdown and then once selected they enter the hours they worked each day and then it saves it to a database. Here is my problem it seams to be saving the id and not the name that it is suposed to. But heck at least I got the darn thing to save to the database.

Database information:
table = newemployees
id <- primary key (auto incrament)
firstname
lastname

table = payroll
id <- primary key (auto incrament)
name  <--- it is incerting the ID from the table newemployees
hours
date

PLEASE HELP.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<cfparam name="id" default="1245">

<cfquery datasource="*********" name="newemployees">
	select id,firstname,lastname
    from newemployees
     order by lastname, firstname
</cfquery>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<cfoutput>
    <body>
<form id="form1" name="form1" method="post" action="save_hours.cfm">
  <p>
  <table width="396" border="1">
  <tr>
    <td width="215">Please select your name here</td>
    <td width="165">
   <select name="id">
   		<cfloop query="newemployees">
            <option value="#id#" type="text" <cfif id EQ #id#>selected</cfif>>#lastname#,&nbsp;#firstname#</option>
        </cfloop>
    </select>
    </td>
  </tr>
  <tr>
    <td>Please enter your hours here</td>
    <td><input name="hours" type="text" id="hours" value=""/> </td>
  </tr>
  <tr>
    <td>Please enter todays date here</td>
    <td><input name="date" type="text"  id="date" value = "#dateformat(now(), "yyyy-mm-dd")#" /> </td>
  </tr>
</table>
 
  </p>
<input type="submit" name="sr" id="save" value="Save" />
</form>
</body>
</cfoutput>
</html>

*************Page2*********************************

<cfquery datasource="*********">
	insert into payrolle16
    (name, hours, date)
    values ('#form.id#', '#form.hours#', '#dateformat(date, "YYYY-MM-DD")#')
</cfquery>
 
<cfif sr EQ "Save">
<cflocation url="Index.cfm?id=#id#" addtoken="no">

<cfelse>
<cflocation url="Index.cfm?id=0" addtoken="no">

</cfif>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros