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 Link to comment https://forums.phpfreaks.com/topic/81968-solved-concatenate-text-output/ 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) Link to comment https://forums.phpfreaks.com/topic/81968-solved-concatenate-text-output/#findComment-416512 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 Link to comment https://forums.phpfreaks.com/topic/81968-solved-concatenate-text-output/#findComment-416517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.