Copy link to clipboard
Copied
I got a query...gives list of names.
i want to display
11. Peter
12. Jessica
32. Leo
15. Jamie
36. Edward
how i get static number infront of my query result.
static number is not in order.
Copy link to clipboard
Copied
From where do these numbers come?
Copy link to clipboard
Copied
numbers are hardcoded.
i got 15 numbers...this is fixed.
query result maybe 14 or 13 or 15 or 12...this result will never exceed 15.
i want to display query result with hardcoded number.
11. Peter
12. Jessica
13. Leo
14. Jamie
15. Edward
Copy link to clipboard
Copied
Is there any correlation between the number and name?
Copy link to clipboard
Copied
No correlation.
Numbers are static number in squecne. Number is range.
Name are query result.
How can i display both together?
Copy link to clipboard
Copied
#QueryName.CurrentRow# ????
Copy link to clipboard
Copied
Amm85 wrote:
I got a query...gives list of names.
i want to display
11. Peter
12. Jessica
32. Leo
15. Jamie
36. Edward
how i get static number infront of my query result.
static number is not in order.
You could use the function queryAddColumn to add the numbers as a separate column to the query.
Let us suppose the name of the query is "myQuery". Then you could proceed as follows
<!---Define your "static" list of numbers --->
<cfset staticList = "11,12,32,15,36,13,23,14,33,16,44,31,17,34,18">
<!--- Create an array from the static list. --->
<cfset staticNrArray = ArrayNew(1)>
<cfset staticNrArray = listToArray(staticList)>
<!--- Add the array as a column to the query. --->
<cfset nColumnNumber = QueryAddColumn(myQuery, "staticNr", "integer", staticNrArray)>
<!--- Verify whether it works as expected--->
<cfdump var="#myQuery#">
The list I have given here has 15 numbers. This will naturally instruct ColdFusion to add a new column named staticNr, having 15 rows. You might like to know that the queryAddColumn function enables padding.
Here is how it works. Suppose that the query originally had only 8 rows before you added the column(of 15 rows). Then, in the new query, ColdFusion would pad the last 7 rows of the other columns with null values. If the original query had 20 rows instead, then Coldfusion would pad the last 5 rows corresponding to the staticNr-column with null values.