Show More button?


On my website, I pull information from a MySQL to make a blog-like setup. However, occasionally the message will be a little too long. How can I limit the characters shown, then have a show more button (like on Youtube descriptions) to show the rest of the message, without completely bogging down the page?


You don`t need PHP for that, just put your text into

and use JQuery.
Google: javascript show/hide content


But, if you want to use PHP for it because the rest of the blog is in PHP, you can just check for the length of the string – len($blogtext) – and if it is over the max, just use substr and take the part you want minus room for a “more” button. Add the more button as a and steer it to the more page. Or, if it is in a DIV, you can change the width or height of it with Javascript if the MORE button is push. Depends a lot on how you page is set up. Do you have a live page to show us for other ideas? Well a couple ideas to think about, good luck…


Well if you use PHP you have to redirect/reload the page, because PHP is a server side script language OR you can use PHP as a PERL extension than you can do exactly what you wannt :smiley:

Though i would recommend you to use javascript :slight_smile: