SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    listAppend & CHR 32 to create a space not functioning

    Hi. I use the following listAppend:

    Code CFM:
    <cfset variables.datestr = ListAppend( variables.datestr, variables.newDate, ', ' & CHR(32) )>

    I use the CHR(32) to create a space after the comma in the output but for some reason is it not working. Does anybody has an idea why this isn't working?
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    from the cfdocs:
    ListAppend(list, value [, delimiters ])

    delimiters --

    A string or a variable that contains one. Character(s) that separate list elements. The default value is comma.

    If this parameter contains more than one character, ColdFusion uses only the first character.
    answers your question?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    from the cfdocs:
    ListAppend(list, value [, delimiters ])

    delimiters --

    A string or a variable that contains one. Character(s) that separate list elements. The default value is comma.

    If this parameter contains more than one character, ColdFusion uses only the first character.
    answers your question?
    Maybe I'm stupid but I have take the CHR(32) away but still don't get a space. Can you please tel how to create a space Rudy using listAppend?
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    i don't think you can do what you're after with ListAppend

    try a loop where you simple concatenate each list element onto the end of a string variable
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    i don't think you can do what you're after with ListAppend

    try a loop where you simple concatenate each list element onto the end of a string variable
    Hi Rudy I lost the plot a bit. How do you mean?

    Thank you in advance.
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  6. #6
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy. Is it not possible to set the date_format in the query and then use the value in a valueList? Because in a valueList you have the option to create a space after the comma?
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  7. #7
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy. Is it not possible to set the date_format in the query and then use the value in a valueList? Because in a valueList you have the option to create a space after the comma?
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by donboe View Post
    Hi Rudy. Is it not possible to set the date_format in the query ...
    i lost the plot a bit -- what query?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    i lost the plot a bit -- what query?
    This is the complete query to output the activity:
    Code:
          	SELECT
                    CL.category_id
              ,	C.language_abbr
              ,	C.category_name
              ,	CH.photo
              ,	AL.activity_id
              ,	AL.activity_persons
              ,	AL.activity_price
              ,	A.language_abbr
              ,	A.activity_name
              ,	A.activity_title
              ,	A.activity_description
              ,	AD.activity_date
              ,	TL.team_leader_id
              ,	TL.team_leader_name_eng
              ,	TL.team_leader_name_gre
              ,	TL.team_leader_description_eng
              ,	TL.team_leader_description_gre
              ,	TLP.photo AS tl_photo
            FROM
                    category_list CL
    				INNER
            	JOIN categories C
              	ON CL.category_id = C.category_id
               AND C.language_abbr = <cfqueryparam cfsqltype="cf_sql_char" value="#Trim( Session.language )#" />
    				INNER
            	JOIN category_headers CH
              	ON CL.category_id = CH.category_id 
    				INNER
            	JOIN activity_list AL
              	ON CL.category_id = AL.category_id 
    				INNER
            	JOIN activities A
              	ON AL.activity_id = A.activity_id
               AND A.language_abbr = <cfqueryparam cfsqltype="cf_sql_char" value="#Trim( Session.language )#" />
      			INNER
      				JOIN 	activity_dates AD
        				ON	AL.activity_id = AD.activity_id	
            LEFT
            	JOIN team_leader_activities TLA
              	ON AL.activity_id = TLA.activity_id   
    				LEFT
            	JOIN team_leaders TL
              	ON TLA.team_leader_id = TL.team_leader_id      
     				LEFT
            	JOIN team_leader_photos TLP
              	ON TL.team_leader_id = TLP.team_leader_id        
            WHERE
            		AL.activity_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#Trim( Url.activity )#" />
    The dates are coming from the table activity_dates. And I would like to have my output like this:

    09/09, 10/09, 15/09, 20/09

    Thank you in advance foar looking at it
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  10. #10
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy, that was indeed the way to go.

    This is how I solved it:

    Code:
    DATE_FORMAT( activity_date, '%d/%m') AS newDate
    and than after the query

    Code:
    <cfset dateList = valueList ( getDetails.newDate, ", " )>
    and it is working great. Thanks for the input.
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  11. #11
    SitePoint Member
    Join Date
    Sep 2011
    Location
    Romania
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you can have spaces in a list. You should try using Arrays instead.

  12. #12
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by viaromania View Post
    You should try using Arrays instead.
    you think arrays will allow spaces??
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  13. #13
    SitePoint Member
    Join Date
    Sep 2011
    Location
    Romania
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it works. Try this code:

    <cfset a = ArrayNew(1)>

    <cfset a[1] = "1">
    <cfset a[2] = " ">
    <cfset a[3] = "a">

    <ul>
    <cfloop from="1" to="#ArrayLen(a)#" index="i">
    <cfoutput><li>|#a[i]#| - #ASC(a[i])#</li></cfoutput>
    </cfloop>

  14. #14
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The valuelist as described above gave me the desired result.
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •