Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    How do you only show a certain number of words from the database

    I am just intergrating my forum into my home page. Well the announcements bit anyway. Although I cant exactly go and post an entire Story on my nice spacey forum and then expect it to appear nicely in a small little box with the heading "Updates".

    Now I do want to show some text and not just the title of the post so it makes the "Read More" link Phychologically more clickable

    So i was wondering am I able to only show something like 20 words using a PHP or MySQL (since its comming from a Database) function at all do you think.

    Any ideas are welcome.
    Thank you

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    SELECT
     SUBSTRING_INDEX(yourcol,' ',20) AS foo
    FROM
     table
    That'll extract everything up to the twentieth space.

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    Thank you very much


  •  

    Posting Permissions

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