SitePoint Sponsor

User Tag List

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

    Splitting content from one field (6 paragraphs) in two

    I need to divide the content from one field in my database(6 paragraphs) in two equal parts of three paragraphs. What would be the best way to that? I thought it was possible in my query but it seems not. Any advise would be more than welcome.
    “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,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    it ~is~ possible in the query, but you looked like you were about to run two separate queries, one for the first 3 paragraphs, and another for the rest

    and that's wasteful

    grab everything in one query, then break it up with coldfusion

    in your other thread, you were using CHAR(13,10) as the paragraph marker, so i would try that with ListGetAt
    Code:
    <CFOUTPUT>
    <p>#ListGetAt(queryname.content,1,CHAR(13,10),FALSE#</p> <!--- 1st paragraph --->
    <p>#ListGetAt(queryname.content,2,CHAR(13,10),FALSE#</p> <!--- 2nd paragraph --->
    <p>#ListGetAt(queryname.content,3,CHAR(13,10),FALSE#</p> <!--- 3rd paragraph --->
    <p> ... other content ... </p>
    <p>#ListGetAt(queryname.content,4,CHAR(13,10),FALSE#</p> <!--- 4th paragraph --->
    <!--- etc. --->
    </CFOUTPUT>
    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,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy, thank you for the responce. It looks like a good structure I only get the following error:

    Invalid CFML construct found on line 14 at column 59.
    ColdFusion was looking at the following text:

    #

    and then:

    14 : <p>#ListGetAt(getContent.content,1,CHAR(13,10),FALSE#</p>
    15 : <p>#ListGetAt(getContent.content,2,CHAR(13,10),FALSE#</p>
    16 : <p>#ListGetAt(getContent.content,3,CHAR(13,10),FALSE#</p>

    What could be the reason?

    Thank you
    “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,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by donboe View Post
    What could be the reason?
    looks like someone forgot the parentheses to close the function

    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,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stupid, stupid, stupid, that I didn't see that Now on the other hand I get the error that Variable CHAR is undefined. ?

    Sorry for my ignorance, but so far I never had to deal with something like this.

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

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by donboe View Post
    ...I get the error that Variable CHAR is undefined. ?
    you are learning rather quickly that i didn't test my code, eh

    (i have an excuse: my computer died last month, i had to buy a new one, and i still haven't gotten around to installing coldfusion again -- i absolutely ~hate~ installs, last time i spent days, literally days, trying to get the damned thing working, declaring the datasource or whatever you have to do to get it to talk to mysql... i am looking forward to that experience again just like you would look forward to having a root canal)

    anyhow, replace CHAR(13,10) with CHR(13)&CHR(10)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy this seems to work indeed. Great stuff. I have one last question though. I try to understand the CHR(13)&CHR(10) since within my content I have some lists as well. I though by sticking those in a paragraph I could output them as well but that doesn't seem to work? What should I do to count a list next to the paragraphs?

    (i have an excuse: my computer died last month, i had to buy a new one, and i still haven't gotten around to installing coldfusion again -- i absolutely ~hate~ installs, last time i spent days, literally days, trying to get the damned thing working)
    I know the feeling. I had the same thing last month. What a disaster. You loose so much time
    “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,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by donboe View Post
    What should I do to count a list next to the paragraphs?
    i have no idea what your content actually looks like, aside from the fact that i know you're using carriage return and line feed to delimit your paragraphs

    if your content is more complicated than that, i'm sorry, i think that would be a new thread
    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,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Rudy. I will give this some more thought, before I come back to this. Anyway thank you again.
    “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
  •