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
Share on other sites

The text of text area must Break after 50 chars. And get onto a new line as it does in the editor of here SMF. When we are typing. We don't have to go down, it automatically Breaks ;) I want that :)..

 

THANKS for the answer though ;)

Link to comment
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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! :)

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.