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)

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


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<cfparam name="id" default="1245">

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

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<form id="form1" name="form1" method="post" action="save_hours.cfm">
  <table width="396" border="1">
    <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>
    <td>Please enter your hours here</td>
    <td><input name="hours" type="text" id="hours" value=""/> </td>
    <td>Please enter todays date here</td>
    <td><input name="date" type="text"  id="date" value = "#dateformat(now(), "yyyy-mm-dd")#" /> </td>
<input type="submit" name="sr" id="save" value="Save" />


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

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

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