Results 1 to 2 of 2
  1. #1
    Abina's Avatar
    Abina is offline Master
    Join Date
    Dec 2009
    Location
    United States
    Posts
    1,073
    Thanks
    1
    Thanked 6 Times in 4 Posts
    Feedback Score
    0

    Default extracting list from a database

    I have a table that holds responses to a questionaire, several of the questions ask respondents to provide several pieces of data seperated by a comma or pipe and ending with a return. recruiting for example the user lists name, activity, date and return. the db entry in the response field appears as such:

    Michael Tarantino | Transferred to another agency | 9/28/2009 Tyre Lewis Jr. | Transferred to another agency | 7/16/2008 Joshua Shapiro | Intern - Separated | 8/18/2007


    my customer now wants the data displayed in a table as part of a report.
    What is the best way to extract this data so that it cam be displayed in a table?

    I have tried using listgetat and temp vars, however the return value is causing me fits, the code below works fine if there is only set of data in the field. but with a field value like above it only gives the first set of values and the last temp var would have the date and name in stead of just the date.

    Code:
    <cfloop query="rpt_GetBackground">
    		<cfif question_id EQ 1279 and isDefined('response')>
    			<cfset temp_tln = ListGetAt(response, 1,',')>
    			<cfset temp_tlt = ListGetAt(response, 2,',')>
    			<cfset temp_tll = ListGetAt(response, 3,',')>
    			<!--- <cfset tem_rtn =ListGetAt(response, 4,'')> --->
    			<tr><td>#temp_tln#</td><td>#temp_tlt# </td><td>#temp_tll#<!--- #tem_rtn# ---></td>	</tr>
    		<cfelseif question_id EQ 1315 and isDefined('response')>
    		<cfset temp_tmn = listGetAt(response, 1,',')>
    			<cfset temp_tmt = listGetAt(response, 2,',')>
    			<cfset temp_tml = listGetAt(response, 3,',')>
    			<!--- <cfset tem_rtn =ListGetAt(response, 4,'')> --->
    		<tr><td>#temp_tmn#</td><td>#temp_tmt# </td><td>#temp_tml#<!--- #tem_rtn# ---></td>	</tr>
    		
    		</cfif>
    </cfloop>

  2. #2
    numberone's Avatar
    numberone is offline Senior
    Join Date
    Jan 2010
    Posts
    623
    Thanks
    0
    Thanked 1 Time in 1 Post
    Feedback Score
    0

    Default

    Can you provide a working code sample? The one above can't be run because it needs that query, and when you change it so that it doesnt, it throws an Invalid Index error. If I could execute the code and see the problem, I could help you.

    Off the top, seems like you could use listlen with the delimiter option to detect the pipe formatted answer, then just loop over it using different delimiters. So, if each row was delimited by a return character and each item in the row was delimited with a pipe, you could display it in a table like this:

    <cfset response = "Michael Tarantino | Transferred to another agency | 9/28/2009 #chr(13)#Tyre Lewis Jr. | Transferred to another agency | 7/16/2008 #chr(13)#Joshua Shapiro | Intern - Separated | 8/18/2007">

    <cfoutput>
    <table border="1">
    <cfloop list="#response#" index="i" delimiters="#chr(13)#">
    <tr>
    <cfloop list="#i#" index="j" delimiters="|"><td>#j#</td></cfloop>
    </tr>
    </cfloop>
    </table>
    </cfoutput>

Similar Threads

  1. Basic html tutorial
    By Richaexpert in forum Graphics Design & Web Design
    Replies: 26
    Last Post: 08-11-2011, 02:53 AM
  2. [Link Building] *** List with 200 Do-Follow Forums List
    By nilulk in forum Search Engine Optimization
    Replies: 52
    Last Post: 06-02-2011, 09:06 PM
  3. Replies: 0
    Last Post: 04-22-2010, 07:25 PM
  4. List Building Strategies For Increasing Your Earnings And List Size!!
    By DotComBum in forum Marketplace - Buy, Sell & Trade
    Replies: 1
    Last Post: 04-22-2010, 01:14 AM
  5. Replies: 0
    Last Post: 10-24-2008, 07:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Partners: BOSTON WEB DEVELOPER, LLC   |   WEBCOSMO CLASSIFIEDS