Jump to content

[SOLVED] concatenate text output


jb60606

Recommended Posts

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

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.