Text Limit!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Text Limit!

Post by Mr. Tech »

Hi!

I am creating a links script.

New what it does is show the title, description etc and then has a more info button.

Now on the page with the title, description etc I want to limit the amount of text shown from the description but when you click more info it shows it full.

E.G:

On The Main Page:

This is a cool product! I reccomend it and...

On The More Info Page:

This is a cool product! I reccomend it and you should buy it now!!!

Any ideas?

Thanks!
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

I'd use substring or something to copy the first x chars into the variable you display in your overview. Or write yourself a function that gives you the first x words of a string (seperated by " " blank) so the words wont be cut.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if you're using a database that supports it you might query only the amount of characters needed.
e.g. http://www.mysql.com/doc/en/String_func ... ml#IDX1182
Post Reply