jb60606 Posted December 17, 2007 Share Posted December 17, 2007 If I have a field (type = 'text') in my database called "comments"; containing various amounts of text submitted by users. I want to display those comments on a PHP web page, though I want to concatenate them to only show, say, the first 5 or 6 words of each individual comment. e.g.: "I think 300 sucked. The acting was terrible, the special effects were nothing I've never seen before and I question the timing of this movie's release." should read: "I think 300 sucked. The acting..." Any ideas... Thanks Quote Link to comment Share on other sites More sharing options...
corbin Posted December 17, 2007 Share Posted December 17, 2007 http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring Maybe something like: SELECT SUBSTRING(comments, 0, 50) FROM comments WHERE movie_id = '<some movie id>' That would give you the first 50 characters from the comments column. (PS Everytime I've heard concatenate, it's meant to combine strings, not shorten them x.x) Quote Link to comment Share on other sites More sharing options...
jb60606 Posted December 17, 2007 Author Share Posted December 17, 2007 DOH! I meant "truncate". Thanks for your help; it works perfectly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.