Gossamer Forum
Home : Products : DBMan : Customization :

50 charecter

Quote Reply
50 charecter

$rec{'Info'} = substr($rec{'Info'},0,50);
$rec{'Info'} .= "...";
}[/code]I use code above to show 50 char. of Info field on short page.
Now some record try to make their record to get more views by put a dot and breakline and dot and again and again...so these record will look like this
.
.
.
.
.
.
.
how can I use this mod by get rid of this problem?

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: 50 charecter In reply to
You should use the following codes in the sub html_record routine:

Code:

$rec{'Info'} = substr($rec{'Info'},0,50) . "..." if (length($rec{'Info'}) > 50);


You are missing concatemnet values of . "...".

Regards,

Eliot Lee
Quote Reply
Re: 50 charecter In reply to
Thank alot,Eliot. :)

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: 50 charecter In reply to
Hi, Eliot
I test ti but it still be as
.
.
.
Indeed i want it go to be
.... (without breakline in short page)

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: 50 charecter In reply to
Try reducing 50 to another number...

Trust me...these codes work...I have them in a bunch of my cgi scripts...

Regards,

Eliot Lee
Quote Reply
Re: 50 charecter In reply to
Try this variation taken from the FAQ noted below:


if (length($rec{'Info'}) >50) {
$rec{'Info'} = substr($rec{'Description'},0,50);
$rec{'Info'} .= "...";
}

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: 50 charecter In reply to
That's effectively the same code.

Anyway, I think we're missing the problem here...

In Reply To:
Now some record try to make their record to get more views by put a dot and breakline and dot and again and again...
Sounds to me like the problem is the new lines, so perhaps you should strip them first:

$rec{'Info'} =~ s/\n//g;

Hope you sort things out.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: 50 charecter In reply to
Really....huh? Because it works JUST fine in my script without the line break codes, ASTROBOY! Tongue

Regards,

Eliot Lee
Quote Reply
Re: 50 charecter In reply to
Yes, it is .it not work with mine.I wonder if there is some routine in .cgi file I missed.May be I modified the .cgi file so it not work..
i also have problem with get breakline html code < br > appear in database file at everywhere when user enter a breakline in textarea field.

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: 50 charecter In reply to
Act:

Are you including at the top of your html_record and/or html_record_long the following:

$rec{'Description'} =~ s/\n/<BR>/g;

This would convert line breaks for you without having to place the break tags within your database.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: 50 charecter In reply to
Eliot, I am not dissing your code. All I'm saying is, to me, it sounds as though people are putting in newlines to help "pad out" their records (that's how I read it anyway).

Your substr code no doubt works perfectly, all I was suggesting was to include the find/replace code as well.

Just trying to help...

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: 50 charecter In reply to
Yes, Loisc
$rec{'Description'} =~ s/\n/<BR>/g;
is included at the top of long page.
Is there something wrong in cgi file?


Regards,
Act.
I am new to cgi, Thank you for your help.