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
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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.