Jump to content

Can TextArea has automatic line break


shebbycs

Recommended Posts

60656925855210789332.jpg


 


In operation or action & results using textarea


 


For example if person insert or input data and when the data reached finish line it will automatically line break and save to database


 


My problem was  when calling from database, the data will output long text instead of user input which has linebreak


 


Any solution please where the user input data via textarea it will automatically recognized line break


Edited by shebbycs
Link to comment
Share on other sites

Use nl2br, which will convert the regular \r and \n line breaks into the <br>s HTML actually cares about.

 

But I created sample program

//linebreaks.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="linebreaks2.php" method="post"> 
<textarea name="ye" cols="40" rows="10" ></textarea> 
<input type="submit" name="submit" value="press"> 
</form> 
</body>
</html>


//linebreaks2.php
<?php
if(isset($_POST['submit']))
{ 
 $a = nl2br($_POST['ye']);
 echo $a;
}
?>

linebreaks.php and linebreaks2.php screenshot after i input 

 

28666291850466265835.jpg

 

83506090379096576292.jpg

 

The word was not in line break 

Link to comment
Share on other sites

There aren't any line breaks in there. Are you talking about word wrapping now?

 

Sorry my english will be bad but I try first

 

28666291850466265835.jpg

 

Based on this picture, look on the first line of s when come to the second line of s, I never put the "Enter" keystroke and that leads to the second photo where all s in one line

 

can textarea be coded when its reached limit of column it can line break for second line without pressing "Enter" keystroke?

Link to comment
Share on other sites

Have you looked at the link I gave?

 

 

yeah I saw but all was text where mine is text in textarea

 

28666291850466265835.jpg

 

ok i post another picture

 

26398460263863982589.jpg

 

 

If you see in field let said now I want to input one data which is line number 13 that show

 

Time = 10.00 am

 

Task = Morning Briefing

 

 

Operation = 1) Sales Performance Review

                     Staff A = RM 5,000.00

                     Staff B = RM 3700.00

                     Staff C = RM 4,200.00

                     2) Staff Performance Review

                     a) Service Performance Review

                     b) Attendance Performance Review

 

and all this data is inserted in one line where the operation input data I label as text area

 

My data can be shown same like this picture above using that nl2br function but only if the person who input data in text area using "Enter" keystroke to move new line but as we know when we write in textarea after it reached lts limit column it will automatically move to the next line but still if using nl2br function, the data were not in linebreak same according to the first one i mention

 

About  word wrap how it will be balance the word if first line for example was 25 but second form the first line was 30 

Link to comment
Share on other sites

About  word wrap how it will be balance the word if first line for example was 25 but second form the first line was 30

Not sure what you're saying but try the function out. Don't forget the third parameter which is what it should use as the wrapping string.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.