karatekid36 Posted December 18, 2007 Share Posted December 18, 2007 Below is an image of a forum that I read and I like how they have some of the message displayed, but then they cut it off with a more button at the end. I was curious if anyone might know how to do this? Thank you in advance for any help. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 18, 2007 Share Posted December 18, 2007 They just use the substr() function to show a limited amount of text, then add the "..." to the end. Then the more link will lead to a page that will have the message ID in the URL, and it will display the entire message on that page. www.php.net/substr Quote Link to comment Share on other sites More sharing options...
karatekid36 Posted December 18, 2007 Author Share Posted December 18, 2007 When pulling the a paragraph from a table, what would be the best way to set it up? Do you create a variable that is equal to what is being pulled from the table or do you just use it when echo-ing the data? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 18, 2007 Share Posted December 18, 2007 Here, I will give you some example code to look at. <?php //select message from db $query = mysql_query("SELECT message FROM table"); $row = mysql_fetch_assoc($query); //This will echo out the ENTIRE message echo $row['message']; //Now to change it so it only echos out some of the message, we do this $message = substr($row['message'], 0, 15); echo $message.'...'; //will print the first 15 letters, then add a ... ?> Quote Link to comment Share on other sites More sharing options...
karatekid36 Posted December 18, 2007 Author Share Posted December 18, 2007 Thank you very much. I know understand how this works. I got it to worl exactly the way I needed it to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.