Forum Moderators: coopster

Message Too Old, No Replies

restricting word count

         

Smad

10:12 am on Sep 13, 2004 (gmt 0)

10+ Year Member



I have looked through umpteen articles on google and can not find what i am looking for. Can someone point me in the right direction for restricting the results. for example if a news article is submitted i want to show a brief description like the first 20 words and then offer a link to the whole article.

Thanks

Mike

Zipper

11:31 am on Sep 13, 2004 (gmt 0)

10+ Year Member



use substring()

eg: "SELECT substring(fieldname, 1, XX) FROM tablename";

XX is the number of characters.

RonPK

2:12 pm on Sep 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your articles are stored into a MySQL database, try the method SUBSTRING_INDEX(string, delimiter, count)

SELECT SUBSTRING_INDEX(article, ' ', 20) FROM articles WHERE ...