ggood morning,
i am new to This forum. I am working on a PC, using MySQL and Coldfusion 9.
The query below does a multiple row insert just fine with one problem. The query is inserting the same ID of one of my students the number of times that I specify. Is there a way to loop through the insert so that all of the different ID's of the inactive student are inserted for each new row? Am I missing something obvious?
<cfquery name="maxID" datasource="master">
select max(stuid) as maxid from student
</cfquery>
<cfquery name="student" datasource="master">
select count(stuid) as inactive_number
from name
where type = 'senior'
AND squadlt = '#session.user_id#'
AND CITY = 'richmond'
AND STATUS = 'i'
order by stuid
</cfquery>
<cfquery name="student2" datasource="master">
select stuid, fname as name
from name
where type = 'senior'
AND squadlt = '#session.user_id#'
AND CITY = 'richmond'
AND STATUS = 'i'
order by stuid
</cfquery>
<cfset initialmaxid1 = (#maxID.maxid# + 1)>
<cfset initialmaxid2 = (#initialmaxid1# + #student.inactive_number#)>
<cfset list1 = "#stuid#">
<cfloop from="#initialmaxid1#" to="#initialmaxid2#" index="i">
<cfquery name="insertabsentee" datasource="master">
INSERT INTO student_attendance (stuid, name)
VALUES (#i#,'#list1#')
</cfquery>
</cfloop>