Limit the word count for each record returned

Posted on 2006-04-22
Last Modified: 2013-12-24
Hello everybody,

I have a recordset the returns a maximum of five of the latest records from my database with ColdFusion. What I would like to do is limit the word count as well for each record returned, for example:

Current Method:
This is some text returned from my query.

The way I would like it to run:
This is some text returned…

I want to limit the word count returned as well and add the three dots (…) at the end to let users know there is more.

Any thought on how to achieve this?

Thanks in advance,
Question by:EnginesofCreation
    LVL 36

    Expert Comment

    <cfquery name="sometext" datasource = "mydata">
    select * from mytable

    <Cfloop query=Sometext">

    #left(sometext.mytext, 75)# <a href=""> More ...</a>


    LVL 36

    Accepted Solution

    oops of course that doesn't do word count, just chars...

    this will do words

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
    The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
    The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now