Go Back   WebMasters.org Forums > Website Design & Development > PHP Forum

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-09-2011, 06:51 AM
Junior Member
 
Join Date: Aug 2011
Posts: 15
Default how to auto break lines?

Hello;
I send long texts into the database via a form which includes textareas. Then I want to get that content in a new file. However, there are very long lines which I can't limit either by table width or another method. I use <pre>...</pre> tags as well in the output file but that works as long as I manually break the lines while the text is still in the form, which is quite impractical as I paste the text into the textarea from another source, such as ms-word. Is there a method to limit the line lenght that is retrieved from the database?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-10-2011, 07:29 AM
Junior Member
 
Join Date: Jul 2011
Location: India
Posts: 4
Default

Depends if theres a break in the words, I would just use wordwrap like above post said, or if there is space use nl2br
__________________
Dog Poop Bags poop bags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-10-2011, 12:46 PM
Senior Member gay
 
Join Date: Jul 2011
Posts: 107
Default

<?php
// Limit $summary to how many characters?
$limit = 100;

// your database query here
...
....

....
..

if (strlen($query) > $limit)
$query = substr($query, 0, strrpos(substr($query, 0, $limit), ' ')) . '...';
echo $query;
?>

Hope this helps...
__________________
car rental cyprus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:34 AM.



Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
vB Ad Management by =RedTyger=