I cannot seem to be able to create a list of names from a list of id's. Keeps doubling the list up when all I want is one list.
I need "John,Sara,Jack,Jill"
I have "112,115,97,420"
I want to query the DB and get the names from the id and create a comma list like above, however they keep doubling based on my code below. Any idea how to fix this?
Here's the code
<cfset mylist = "112,115,97,420">
<cfset newemplist = "">
<cfloop index="newlist" list="#mylist#" delimiters=",">
<cfquery name="getemp" datasource="DB">
select * from employees where emp_id = #newlist#
<cfif #newemp# eq "">
<cfset newemp = "#document#">
<cfset newemp = "#newdoc#,#document#">
It creates John John,Sara, John John, Sara, John, Sara, Jack, John John, Sara, John John, Sara,Jill..... Or something like that. Any ideas would be great! Thanks