The purpose of the ValueList() function is to take values in a field from multiple records in the record set and make a list out of them. Which, if you had a well normalize database design, you would be retreiving.
ID 1 firstname.lastname@example.org 2 email@example.com 3 firstname.lastname@example.org
You have a un-normalized table field that contains a list of values. I presume you would like to process the items in that list individually.
The list functions are probably what you would like to use.
<cfloop list="#qry_email.email#" item="x">
There are many other list functions you can use, listFirst(), listLast(), listGetAt(), etc.
Of course the professional in me would suggest that you properly normaize your database design if at all possible.
already try that but it only output the last one. I think what i am going to do is use the listFirst(), ListLast() and LitGetAt() . ListGetat() to get the second email from the list, since i have three text boxes with three emails but how can i count for the postion to get email2?
already try that but it only output the last one.
Then something is not working as I would expect it to work. But I don't really know wht you tried, because you didn't actually show what you tried.
You would use 2 to get at the send item in a list. ColdFusion is one based so the first item in a list is 1, the second is 2, and so on.
this code returned sperate such as
<cfloop index ="ListElement" list ="#qry.email#>
but i don't know how to count that how many email is returned and put each into each text box
Looping across a list occurs automatically. You don't need to know how many list-elements there are. However, as Ilssac says, you could use listLen(qry.email) where needed (I have assumed the delimiter is a comma).
Your answer is almost there! You could do the following in a form:
<cfset emailCount = 1>
<cfset emailList = valueList(qry.email)>
<cfloop index ="ListElement" list ="#emailList#">
<cfoutput><cfinput type="text" name="email_&#emailCount#" value="#ListElement#"></cfoutput><br>
<cfif emailCount LT listLen(emailList)>
<cfset emailCount = emailCount+1>