[thelist] PHP show first 10 words of MySQL field
angello
angello at post.cz
Thu Aug 28 05:14:11 CDT 2003
if you want to do in SQL:
SELECT blobfield AS wholefield, SUBSTRING(blobfield, 1, LOCATE('
',blobfield,'200')) AS shortfield
FROM table WHERE ....
finds first 'space' after 200 character and return it as a new field.
angello
Austin Harris wrote:
>Sorry for the poor title but I am not sure how to describe what I want to do
>concisely...
>
>I have a text field in a db and want to show on one page just the first 20
>words, (more or less) of that field before putting a "view more" link.
>
>Being relatively new to PHP I am not sure what sort of function I need to
>use, searching is tricky without being able to state the problem concisely!
>
>I am guessing I want to count the words, (or characters) and set a cut off
>limit.
>
>All help very much appreciated.
>
>Austin
>
>
>
More information about the thelist
mailing list