Thread: Limiting character count

Limiting character count

From
"roy simkes"
Date:
Hi,
I'm have a field which allows maximum 1000 characters. But when I fecth it I only want to show first 50 characters and then give a link to see the whole data. Is there a way to do this easily with postgresql or I should do this using php functions and other logic things.
I hope I was clear enough I should show something like this:

Hi, I'm new in town and I'm a little bit lost can yo... (more)

Where the whole text is :

Hi I'm new in town and I'm a little bit lost can you show me where is Mr Brown's house?


Be one of the first to try Windows Live Mail. Windows Live Mail.

Re: Limiting character count

From
Christoph Frick
Date:
On Wed, Jul 26, 2006 at 08:47:10AM +0000, roy simkes wrote:

> Hi,I'm have a field which allows maximum 1000 characters. But when I
> fecth it I only want to show first 50 characters and then give a link
> to see the whole data. Is there a way to do this easily with
> postgresql or I should do this using php functions and other logic
> things.I hope I was clear enough I should show something like this:Hi,
> I'm new in town and I'm a little bit lost can yo... (more)Where the
> whole text is :Hi I'm new in town and I'm a little bit lost can you
> show me where is Mr Brown's house?

this depends on what your applications is doing here. if you have a
large list (with the 50 char preview) then your "full view" will likely
be a seperate call (e.g. javascript window, iframe, ...); then you can
use the substring/string manipulation methods of postgres to only get
the data you need. and in the next call get only the full-data that are
requested by the user. but if you are only showing one row and want to
"hide" the full extend there, then you are better of by do you hiding it
in the app.

--
cu

Attachment