i am trying to build a form page that outputs each employee's name, work preference, etc. based on the dates available to work. so far, the page will output the individual tables correctly - including the date. however, the data in the table will only reflect the FIRST date for each employee.
example: you have two dates, 15 employees, options of yes or no for overtime, early, over and charged. when i run the page i see the first table with the first date, all employees names and their choices. the second table shows the second date, all employees names and their choices for the FIRST date.
here's the code i'm using. i've tried several different things and i still cant get the data to output correctly. i've commented the code where the dates work and do not work.
any help will be greatly appreciated - i'm very new to looping.
<!--- shift query --->
<cfquery name="shift_list" datasource="gtoqrcvs" dbtype="ODBC">
select cdsid, wrkd, avail, orderby
from cs_names
where shift = '#shift#' and section = 'oper' <!--- and techno = 'n' ---> and techno < > 's'
order by avail, wrkd, orderby
</cfquery>
<!--- date query --->
<cfquery name="d" datasource="gtoqrcvs" dbtype="ODBC">
select id, date, type
from OT_dates
where date <> ''
</cfquery>
<cfloop query="d">
<table border="1">
<tr>
<td colspan="11" align="center">#d.date#</td><!--- this date increments correctly --->
</tr>
<tr bgcolor="Silver">
<td>Shift #shift#</td>
<td align="center">wrkd</td>
<td align="center">avail</td>
<td align="center">init</td>
<td align="center">pref</td>
<td align="center">acpt</td>
<td align="center">e</td>
<td align="center">eacpt</td>
<td align="center">o</td>
<td align="center">oacpt</td>
<td align="center">chg</td>
</tr>
<form action="OT_acpt_action.cfm">
<input type="hidden" name="shift" value="#shift#">
<input type="hidden" name="date" value="#d.date#"><!--- this date increments correctly --->
<cfoutput query="shift_list">
<!--- this code will make table rows alternate in color - ffffff = white, whatever color you pick for the next row --->
<cfif shift_list.currentrow MOD 2 is 0><tr bgcolor="ffffff"> <cfelse><tr bgcolor="eoffff"></cfif>
<!--- this should pick each persons preferances based on the date from the d -query and the cdsid from the shift_list query --->
<cfquery name="pref" datasource="gtoqrcvs" dbtype="ODBC">
select cdsid, pref, e, o
from OT_list
where cdsid = '#cdsid#' and date = '#d.date#'
</cfquery> <!--- above date in query does NOT increment correctly ??? --->
<!--- above cdsid outputs once for each name and works correctly --->
<td>#cdsid#</td>
<td>#wrkd#</td>
<td>#avail#</td>
<td>#orderby#</td>
<td align="center" width="30"><b>#pref.pref#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="a#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="a#cdsid#" value="1">
</td>
<td align="center" width="30"><b>#pref.e#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="e#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="e#cdsid#" value="1">
</td>
<td align="center" width="30"><b>#pref.o#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="o#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="o#cdsid#" value="1">
</td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" name="c#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" checked name="c#cdsid#" value="1">
</td>
</tr>
</cfoutput><!--- ends output of shift_list query --->
<tr>
<td colspan="11" align="center"><input type="submit" name="submit"><input type="reset" name="reset"></td>
</tr>
</form>
</table>
<!--- a NEW table begins with the next date from the d query --->
</cfloop> <!--- end of d loop --->
example: you have two dates, 15 employees, options of yes or no for overtime, early, over and charged. when i run the page i see the first table with the first date, all employees names and their choices. the second table shows the second date, all employees names and their choices for the FIRST date.
here's the code i'm using. i've tried several different things and i still cant get the data to output correctly. i've commented the code where the dates work and do not work.
any help will be greatly appreciated - i'm very new to looping.
<!--- shift query --->
<cfquery name="shift_list" datasource="gtoqrcvs" dbtype="ODBC">
select cdsid, wrkd, avail, orderby
from cs_names
where shift = '#shift#' and section = 'oper' <!--- and techno = 'n' ---> and techno < > 's'
order by avail, wrkd, orderby
</cfquery>
<!--- date query --->
<cfquery name="d" datasource="gtoqrcvs" dbtype="ODBC">
select id, date, type
from OT_dates
where date <> ''
</cfquery>
<cfloop query="d">
<table border="1">
<tr>
<td colspan="11" align="center">#d.date#</td><!--- this date increments correctly --->
</tr>
<tr bgcolor="Silver">
<td>Shift #shift#</td>
<td align="center">wrkd</td>
<td align="center">avail</td>
<td align="center">init</td>
<td align="center">pref</td>
<td align="center">acpt</td>
<td align="center">e</td>
<td align="center">eacpt</td>
<td align="center">o</td>
<td align="center">oacpt</td>
<td align="center">chg</td>
</tr>
<form action="OT_acpt_action.cfm">
<input type="hidden" name="shift" value="#shift#">
<input type="hidden" name="date" value="#d.date#"><!--- this date increments correctly --->
<cfoutput query="shift_list">
<!--- this code will make table rows alternate in color - ffffff = white, whatever color you pick for the next row --->
<cfif shift_list.currentrow MOD 2 is 0><tr bgcolor="ffffff"> <cfelse><tr bgcolor="eoffff"></cfif>
<!--- this should pick each persons preferances based on the date from the d -query and the cdsid from the shift_list query --->
<cfquery name="pref" datasource="gtoqrcvs" dbtype="ODBC">
select cdsid, pref, e, o
from OT_list
where cdsid = '#cdsid#' and date = '#d.date#'
</cfquery> <!--- above date in query does NOT increment correctly ??? --->
<!--- above cdsid outputs once for each name and works correctly --->
<td>#cdsid#</td>
<td>#wrkd#</td>
<td>#avail#</td>
<td>#orderby#</td>
<td align="center" width="30"><b>#pref.pref#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="a#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="a#cdsid#" value="1">
</td>
<td align="center" width="30"><b>#pref.e#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="e#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="e#cdsid#" value="1">
</td>
<td align="center" width="30"><b>#pref.o#</b></td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" checked name="o#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" name="o#cdsid#" value="1">
</td>
<td align="center">
<font face="Arial" size="1">N<input type="radio" name="c#cdsid#" value="0">
<font face="Arial" size="1">Y<input type="radio" checked name="c#cdsid#" value="1">
</td>
</tr>
</cfoutput><!--- ends output of shift_list query --->
<tr>
<td colspan="11" align="center"><input type="submit" name="submit"><input type="reset" name="reset"></td>
</tr>
</form>
</table>
<!--- a NEW table begins with the next date from the d query --->
</cfloop> <!--- end of d loop --->