Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:51:57+00:00 2026-05-26T01:51:57+00:00

Good afternoon. Currently I am formatting some json from a query and when I

  • 0

Good afternoon.
Currently I am formatting some json from a query and when I get to the point of looping out the query, I get a very odd phenomenon. I specify a startrow of 20 and a endrow of 40. When it runs, I get 19 empty arrays prior to it populating 20-40. How can I get the loop to only return rows 20-40?

<cfcontent reset="Yes" />
<cfset thedata = StructNew() >
<cfset thestruct = StructInsert(thedata, "sEcho", "#NumberFormat(val(url.sEcho),"_")#", 1)>  
<cfset thestruct = StructInsert(thedata, "iTotalRecords", "#NumberFormat(qCount.total,"_")#", 1)>  
<cfset thestruct = StructInsert(thedata, "iTotalDisplayRecords", "#NumberFormat(qFiltered.recordCount,"_")#", 1)>
<cfset thearray = ArrayNew(2)> 
<!--- Populate the array row by row --->

<cfloop query="qFiltered" startrow="20" endrow="40">
    <cfset thearray[CurrentRow][1]=req_name>
    <cfset thearray[CurrentRow][2]=req_departments_name>
    <cfset thearray[CurrentRow][3]=dest_departments_name>
    <cfset thearray[CurrentRow][4]=priority_rank_name>
    <cfset thearray[CurrentRow][5]=issue_subject>
    <cfset thearray[CurrentRow][6]=systems_sub_name>
    <cfset thearray[CurrentRow][7]=tickets_status_name>
    <cfset thearray[CurrentRow][8]=tickets_types_name>
    <cfset thearray[CurrentRow][9]=due_date>
    <cfset thearray[CurrentRow][10]=departments_sub_name>
</cfloop>
<cfset thestruct = StructInsert(thedata, "aaData", thearray, 1)>
<cfoutput>#serializeJSON(thedata)#</cfoutput>

which returns this JSON

{
"iTotalDisplayRecords":"202",
"iTotalRecords":"661",
"aaData":[
[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
["Derek Wolf","","","02- Revenue","Assist in validating error in JCA provided Discount Commission report","","Received","Work Request","Jan 1, 2012",""],
["Katie Hintz","","","02- Revenue","Order\/Install new POS Terminal at Katie's Workstation","","In Progress","Work Request","Oct 31, 2011",""],
["Katie Hintz","","","02- Revenue","Replace #6081 POS Printer at Kim's Desk","","Received","Work Request","Oct 31, 2011",""],
["","","","02- Revenue","Produce Brought To You By...  Video","","In Progress","Work Request","Nov 9, 2011",""],
["","","","02- Revenue","Produce Dept. Spotlight Video","","In Progress","Work Request","Nov 9, 2011",""],
["","","","02- Revenue","Produce Matty T's Pancake Breakfast","","In Progress","Work Request","Nov 9, 2011",""],
["","","","02- Revenue","Produce Fish! Video","","In Progress","Work Request","Nov 9, 2011",""],
["Sextus Selvaratnam","","","02- Revenue","Larger coin hopper system","","In Progress","Work Request","",""],
["Charles Canfield","","","02- Revenue","Ride theme improvment Castle","","In Progress","Work Request","",""],
["Omid Aminifard","","","02- Revenue","Contact Alterface about Desperados","","In Progress","Work Request","",""],
["Dino Kypreos","","","03- Repair","Repair or Replace Radio","","Received","Work Request","",""],
["Josh Cohen","","","03- Repair","SQL Server maintenance and tuning","","In Progress","Work Request","",""],
["","","","03- Repair","Move Weather Station to new Ops area","","Approved","Work Request","Nov 30, 2011",""],
["","","","03- Repair","Weather Station Move","","Approved","Work Request","Nov 30, 2011",""],
["","","","03- Repair","Strip and clean Moving Light fixtures","","Waiting Approval","Work Request","Dec 31, 2011",""],
["","","","03- Repair","Strip and clean Source Four light Fixtures","","Waiting Approval","Work Request","Dec 31, 2011",""],["","","","03- Repair","Replace Bad LCDs on ColorDash Pars LED light","","Received","Work Request","Dec 31, 2011",""],
["Josh Cohen","","","03- Repair","OMRON: repair terminal 4 computer","","On hold by originator","Work Request","",""],
["Amy Walters","","","03- Repair","Radio\/pager maintenance","","Waiting on parts","Work Request","",""],
["Mark Hersey","","","03- Repair","Inspect Ride Speaker Mounts for Safety","","Received","Work Request","Sep 30, 2011",""],
["Brian Gustav","","","03- Repair","Radio\/pager maintenance","","In Progress","Work Request","",""]],
"sEcho":"1"
}

UPDATE

John was able to get an answer for me. Now that I have it working I would like to generate all of the CFSET tags from a list

<cfset listColumns = "tickets_id,departments_sub_name,aging,priority_rank_name,systems_sub_name,issue_subject,tickets_status_name,due_date" />

<cfloop list="#listColumns#" index="thisColumn" delimiters=",">
    <cfset rowarray[listColumnsCount]=#thisColumn#>
    <cfset listColumnsCount ++>
</cfloop>

Instead of getting the column value output, I am just getting the column name in the JSON

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:51:58+00:00Added an answer on May 26, 2026 at 1:51 am

    Your problem is that you’re using CurrentRow as the first index into thearray. So, even though your cfloop correctly skips the first 19 rows, you’re telling it to put the first one in the 20th position in the array, so you get 19 empties before that.

    You can manually subtract 19 from the CurrentRow value, but you’d have to change the calculation every time you change the startrow.

    The better option is to build the inner array separately, and just ArrayAppend that to thearray. This will work regardless of your startrow and endrow values.

    <cfloop query="qFiltered" startrow="20" endrow="40">
        <cfset rowarray = ArrayNew(1)>
        <cfset rowarray[1]=req_name>
        <cfset rowarray[2]=req_departments_name>
        <cfset rowarray[3]=dest_departments_name>
        <cfset rowarray[4]=priority_rank_name>
        <cfset rowarray[5]=issue_subject>
        <cfset rowarray[6]=systems_sub_name>
        <cfset rowarray[7]=tickets_status_name>
        <cfset rowarray[8]=tickets_types_name>
        <cfset rowarray[9]=due_date>
        <cfset rowarray[10]=departments_sub_name>
        <cfset ArrayAppend(thearray, rowarray)>
    </cfloop>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon, I am currently in the very early phase of a new project
Good afternoon, I inherited some C# code from years ago. I have refactored it
Good afternoon, I am currently starting to think & prototype about a (.net based)
Good afternoon, I have a web query in Excel 2002 going against a web
Good afternoon all, I'm using a java.lang.StringBuilder to store some characters. I have no
Good afternoon, I just upgraded my Rails app from 3.1.3 to 3.2.1. Everything is
Good Afternoon, I'm currently trying to build something incredibly simple inside of the Google
Good afternoon, i am currently wrestling with an old .dll which functionality I have
Good Afternoon, I'm currently planning a web-app/service project with a geolocation-enabled user model (lat/lng
Good afternoon I'm facing a trouble, trying to figure out how to use this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.