Selecting and outputting certain columns and rows from a database table
I would like to display a monthly loan payment chart/table that shows payment amounts for various interest rates and loan amounts. The output table will have 9 columns (the first column will be the user-defined loan amounts) and 32 rows (the top row being the user-defined interest rates). I have created a master database table that is 30 columns by 992 rows and includes all of the payment amounts:

I want to allow the user to select a starting interest rate and the increments in which it increases. For example, starting rate of 4.000% and increase increments of .125% (so the top row/header will be 4.000% | 4.125% | 4.250% | 4.375% | 4.500% | 4.625% | 4.750% | 4.875%). Additionally, the user would define the starting loan amount and the increments in which it increases (so the left column might be $200,000, $210,000, $220,000 and so on). I'm trying to accomplish an output like this:
I have been using CF for a number of years, but my knowledge is limited to more simple functions. I started putting together a query, etc. and realized that this extends beyond my knowledge. I am collecting the variable data from the user in a form. I can define the 8 interest rate columns and 31 loan amount rows, but I'm not sure what to do after that. Here is what I started with but wasn't getting the results I'm looking for:
<cfset IntRate1 = #FORM.StartRate#>
<cfset IntRate2 = #IntRate1# + #FORM.RateIncr#>
<cfset IntRate3 = #IntRate2# + #FORM.RateIncr#>
<cfset IntRate4 = #IntRate3# + #FORM.RateIncr#>
<cfset IntRate5 = #IntRate4# + #FORM.RateIncr#>
<cfset IntRate6 = #IntRate5# + #FORM.RateIncr#>
<cfset IntRate7 = #IntRate6# + #FORM.RateIncr#>
<cfset IntRate8 = #IntRate7# + #FORM.RateIncr#>
<cfset LoanAmt1 = #FORM.StartLoanAmt#>
<cfset LoanAmt2 = #LoanAmt1# + #FORM.LoanAmtIncr#>
<cfset LoanAmt3 = #LoanAmt2# + #FORM.LoanAmtIncr#>
<cfset LoanAmt4 = #LoanAmt3# + #FORM.LoanAmtIncr#>
...
<cfset LoanAmt31 = #LoanAmt30# + #FORM.LoanAmtIncr#>
<cfset List = "'#LoanAmt1#','#LoanAmt2#','#LoanAmt3#','#LoanAmt4#',...'#LoanAmt31#'">
<CFQUERY NAME="tabledata" DATASOURCE="dbds" username="username" password="passw">
SELECT LoanAmt, #IntRate1#, #IntRate2#, #IntRate3#, #IntRate4#, #IntRate5#, #IntRate6#, #IntRate7#, #IntRate8#
FROM table
WHERE LoanAmt IN (#PreserveSingleQuotes(List)#)
</CFQUERY>
I'm having trouble getting the loan amount to output since I am using the variables for selecting the column names. I'm hoping there is a simple way to accomplish what I'm trying to do. Any assistance will be appreciated.
