sotusotusotu Posted July 29, 2007 Share Posted July 29, 2007 Hey, I have developed a simple from system that allows users to input some comments. This all works fine, however when I try to retrieve the comments I only want to display 100 characters. I am new to PHP, but was wondering if there is a string function that will let me take the data from a table in my database and then only display 100 characters followed by "..." afterwards. Also I have thought of a potential problem... if someone enters less than 100 characters I only want to show the amount they have entered. can anyone help? Link to comment https://forums.phpfreaks.com/topic/62325-limiting-text-output-from-db/ Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Take a look at substr. In particular the user contributed examples should have something that'll do what you need. Link to comment https://forums.phpfreaks.com/topic/62325-limiting-text-output-from-db/#findComment-310115 Share on other sites More sharing options...
calabiyau Posted July 29, 2007 Share Posted July 29, 2007 also, you should do some kind of checking loop that checks if the last character is a blank space or not and continues to chop off the last letter until it encounters a blank space, cuz it looks ugly to have these 100 character summaries cut off in the middle of a word, like this for examp.... Link to comment https://forums.phpfreaks.com/topic/62325-limiting-text-output-from-db/#findComment-310121 Share on other sites More sharing options...
sotusotusotu Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks guys! I will look up substr. Any ideas how I would go about doing a check loop to see if the word cuts out half way through though? Link to comment https://forums.phpfreaks.com/topic/62325-limiting-text-output-from-db/#findComment-310137 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Did you look at the user contributed examples? Like I said... there should be something there. Link to comment https://forums.phpfreaks.com/topic/62325-limiting-text-output-from-db/#findComment-310140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.