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. Link to comment https://forums.phpfreaks.com/topic/82127-solved-displaying-mysql-data/ 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 Link to comment https://forums.phpfreaks.com/topic/82127-solved-displaying-mysql-data/#findComment-417342 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? Link to comment https://forums.phpfreaks.com/topic/82127-solved-displaying-mysql-data/#findComment-417346 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 ... ?> Link to comment https://forums.phpfreaks.com/topic/82127-solved-displaying-mysql-data/#findComment-417356 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. Link to comment https://forums.phpfreaks.com/topic/82127-solved-displaying-mysql-data/#findComment-417360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.