Jump to content

<textarea> after 50 chars an auto break!


Fsoft

Recommended Posts

Hi,

 

There is a text area in my script / form.

 

In the text area when some thing is written, It goes just long and long and Cuts the entire Page.

 

My Text area value is colleted by using this

<?php

$details = $_POST["details"];

?>

 

NOW I want that Before writing the data to file. This variable details must be run by a test.

 

What test? Well After each 50 charters in the $details, It must insert an auto <br> inside of it. And it must continue until it's done with all the charters.

 

For example, If the $details come with 200 Charters.

It must enter 4 <br> each after every 50 Charters.

 

HMM Looks little complicated to me. Thanks a lot :) Badly waiting for answer :)

 

FAISAL!

Link to comment
https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/
Share on other sites

Well I don't believe that the textarea can alter the looks of the text at a later point. You must do this in two separate areas.

 

First you must make the textarea have 50 cols.

<textarea cols="50" rows="7">

 

Then later you must put in a break every 50 chars. The easiest way is to use the php function wordwrap.

<?php
$string = wordwrap($text, 50);
?>

 

That should do it for you.

Thanks a lot boss :)

 

I use this code ;

 

<?php

$form = "<form method=\"post\" action=\"test.php\">
Name : <input name=\"name\" type=\"text\" size=\"20\">
    <input name=\"submit\" type=\"submit\" value=\"submit\">
    </form>
";


if($_POST["submit"] == submit){
$text_out = wordwrap($_POST["name"], 50);

echo $text_out;
}else
{
    echo $form;
}
?>

 

BUT still, When I insert a string into the text and Put a long line, It don't put a <br> after the 50 charters BUT Just appends the page and Increases the page :((

 

Ok, If this don't work this ..

 

Tell me an easy code that from a line or MySQL we get a text that is a line (300) charters. I want to print it out BUT I want a <br> after 50 chars :)

 

Thanks a lot :)

 

FAISAL!

Thanks dark water,

 

I use this code, But still no change :(

 

<?php

$form = "<form method=\"post\" action=\"test.php\">
Name : <input name=\"name\" type=\"text\" size=\"20\">
    <input name=\"submit\" type=\"submit\" value=\"submit\">
    </form>
";


if($_POST["submit"] == submit){
$post1 = $_POST["name"];
$post = implode("", str_split($post1, 50));

echo $post;
}else
{
    echo $form;
}
?>

 

FAISAL!

Wao,

Very well done :).. But now very small problem the text goes out like this ;

 


Details : This is a test message, If you can see this message, it mean
s your Buy and Sell system is Installed successfully, Plesae
delete /install.php and go to /moderate.php to moderate.You
can delete this query once you get into your moderation. Fo
r more info go and open configuration.php... The password of
Admin Access must be inserted inside of your configuration.
php on the variable admin_pass.... Enjoy the Script. Best W
ishes -> FAISAL SHAH!

 

Is it not possible to put break only when we get a " " space. ?? thanks > I hope it's possible to make teh script perfect. Or it will look bad :(

 

Thanks! :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.