•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 422,829 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,331 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 1773 | Replies: 1
![]() |
•
•
Join Date: Dec 2006
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I am trying to develope a simple application that will record a persons miles per week and total miles but for several different people. I have the code working to accumulate the total, but the problem is how to I get it to accumulate just for the one person and not for all? How do I get it to accumulate for just one team Name? Code is as follows:
<CFQUERY NAME="Mileage" DATASOURCE="#dsn#">
SELECT weeklyMileage, totalMileage
FROM mileage
</CFQUERY>
cfset totalMileage= 0>
<cfloop query="Mileage">
<cfset totalMileage =totalMileage + Mileage.weeklyMileage>
</cfloop>
<cfquery datasource="#dsn#" dbtype="ODBC">
Insert
Into mileage
(dateupdated,teamName,teamLeader,email,weeklyMileage,mileageWeekNumber,comments,totalMileage)
Values
('#Trim(thetime)#','#Trim(teamName)#','#Trim(teamLeader)#','#Trim(email)#','#Trim(weeklyMileage)#','#Trim(mileageWeekNumber)#','#Trim(comments)#','#Trim(totalMileage)#')
</cfquery>•
•
Join Date: Dec 2006
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
ok, now I am really lost. i put in the code to sum up totalMiles grouped by teamName, and took out the loop,total miles now go to 0, what else am I missing?
[code]
<CFQUERY NAME="Mileage" DATASOURCE="#dsn#">
SELECT teamname,weeklyMileage
, SUM(totalMileage) as teamMiles
FROM mileage
GROUP
BY teamname
</cfquery>
<CFQUERY NAME="getMileage" DATASOURCE="#dsn#">
SELECT mileageWeek
FROM weeks
</CFQUERY>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfset weeklyMileage= #form.weeklyMileage#>
<cfset thetime = "#dateFormat(now(),'YYYY-MM-DD')#">
<cfquery datasource="#dsn#" dbtype="ODBC">
Insert
Into mileage
(dateupdated,teamName,teamLeader,email,weeklyMileage,mileageWeek,comments,totalMileage)
Values
('#Trim(thetime)#','#Trim(teamName)#','#Trim(teamLeader)#','#Trim(email)#','#Trim(weeklyMileage)#','#Trim(getMileage.mileageWeek)#','#Trim(comments)#','#Trim(totalMileage)#')
</cfquery>
[code]
<CFQUERY NAME="Mileage" DATASOURCE="#dsn#">
SELECT teamname,weeklyMileage
, SUM(totalMileage) as teamMiles
FROM mileage
GROUP
BY teamname
</cfquery>
<CFQUERY NAME="getMileage" DATASOURCE="#dsn#">
SELECT mileageWeek
FROM weeks
</CFQUERY>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfset weeklyMileage= #form.weeklyMileage#>
<cfset thetime = "#dateFormat(now(),'YYYY-MM-DD')#">
<cfquery datasource="#dsn#" dbtype="ODBC">
Insert
Into mileage
(dateupdated,teamName,teamLeader,email,weeklyMileage,mileageWeek,comments,totalMileage)
Values
('#Trim(thetime)#','#Trim(teamName)#','#Trim(teamLeader)#','#Trim(email)#','#Trim(weeklyMileage)#','#Trim(getMileage.mileageWeek)#','#Trim(comments)#','#Trim(totalMileage)#')
</cfquery>
![]() |
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- IBSoftware Seeking 5 Individuals for Staff & Moderation (Software Development Job Offers)
- C help calculate grand total (C)
- total newb - "passing arg 2 of `strcpy' makes pointer from integer without a cast" (C++)
- Classes and using Static member functions to subtotal/total (C++)
- Problems with displaying total payroll and allowing user to quit by entering a neg. (C++)
- never taught how to show the VAT of a total. I know that u divide by 1.175 (Visual Basic 4 / 5 / 6)
Other Threads in the ColdFusion Forum
- Previous Thread: taxation error in cart weaver
- Next Thread: Need to generate a weekly report in asp -- DateFormat(Now() - 7 days


Linear Mode