3 Replies Latest reply on Nov 9, 2006 8:06 AM by Newsgroup_User

    strange ouput

      the values of variables.otherfundingsource is 9,21,97.

      <cfset variables.otherfundingsource = "9,21,97">
      And before inserting they are same which are 9,21,97.

      debugging: before insert - variables.otherfundingsource: <cfoutput>#variables.otherfundingsource#</cfoutput>

      <cfquery name="r03201_child_insert" datasource ="testdb">
      <cfloop list="#variables.otherfundingsource#" index="variables.otherfundingsource">
      insert into #variables.sub01table#

      values (#variables.index_id#,

      debugging: after insert - variables.otherfundingsource: <cfoutput>#variables.otherfundingsource#</cfoutput>
      after inserting, the output of variables.otherfundings shows only "97"

      why the one value which is "97" is showing up other than three of them which are 9,21,97. what went wrong? shouldn't it output 9,21,97?
        • 1. Re: strange ouput
          Level 7
          Because of this line

          <cfloop list="#variables.otherfundingsource#"

          The index parameter is the variable to store each value of the list as
          it is looped over. So as you loop over the list, [9,21,97], you are
          assigning each of these values to "variables.otherfundingsource". Thus
          at the end of the loop, variables.otherfundingsource is going to equal
          the last value in the list, i.e. 97.
          • 2. Re: strange ouput
            HandersonVA Level 1
            thanks. i need that loop to insert values and need those three values again for something else.
            what can be a way to get three values? should i make a query to retrieve them? is there any other way to get those values without runnig query again?
            • 3. Re: strange ouput
              Level 7
              Just provide an independent variable for your loop iterations so you are
              not overwriting the original variable.

              <cfloop list="#variables.otherfundingsource#" index="sourceID">