Quick Search:
 mySQL: Lead-In Sentence fragment... Jump to:  
Category: >> mySQL >> Lead-In Sentence fragment...  

<< lastnext >>

Snippet Name: Lead-In Sentence fragment...

Description: As a "preview" of text, this MySQL select will return the first few words out of a text field in a database. It returns entire words (doesn't cut them off in the middle) and follows the last word with an elipse "..."

In the PHP, assign $CharactersToDisplay to a number - the approximate number of characters desired (or you can hard-code it if you want).

Comment: (none)

Language: MYSQL
Highlight Mode: MYSQL
Last Modified: March 01st, 2009

SELECT CONCAT(LEFT(NameOfField,LOCATE(' ',NameOfField,$CharsToDisplay)-1),'...')
  FROM TheTable

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org