PDA

View Full Version : Limiting number of characters displayed?


Tim Mousel
Sat 26th May '01, 3:40am
Hello,

In my search results, the profile of a user will be displayed from a mysql database. How can I display only the first 500 characters?

Thanks,

Tim

Theiggsta
Sat 26th May '01, 5:52am
Use LEFT...its a cool little thingie that goes X number of character from the left side of a string...

Now the syntax is simple:
LEFT(string,length)

Here is an example:

SELECT LEFT(text,500) FROM post WHERE postid = '100'

this will return the first 500 characters of the text in post number 100

that should be simple enough to explain...hope that helps :)

Tim Mousel
Sat 26th May '01, 11:07pm
Hi,

Thanks for the input. I've got a fairly large select statement already which starts as SELECT * FROM $table_name WHERE....

Should I just make a new select statement or is there a way to incorporate your select statement and combine it with the one I already have.

Thanks,

Tim

WildWayz
Sun 27th May '01, 2:54am
SELECT LEFT(*, 200) FROM $table_name WHERE ....

think that is what u would use

--James