Jump to content

Recommended Posts

I'm trying to change the textarea's value into pure html.

 

So like if a textarea has this,

Test

Test

I want to change it to html all on one link like this,

Test<br><br>Test

 

How would i do that?ive looked at WYSIWYG editors but they're to much coding for what i want.

Link to comment
https://forums.phpfreaks.com/topic/251223-converting-textarea-text-into-pure-html/
Share on other sites

That isnt working,ill explain it better :)

 

I have some HTML in a mysql database like <div>Test<br>Test</div>,i want to be able to display that like this,

<div>Test
Test</div>

Then save it back in the database like this,

<div>Test<br>Test</div>

How?

 

Im trying to make a homepage welcome thingy,in the admin panel you have a textarea box where you edit the text.when i load the value of the database(Test<br><br>Test) it shows up in the textarea as Test<br><br>Test,i want it to show up as

Test

Test

and when the user gets done editing its going to be like this

Edited

Edited

and when they push save i want it to convert to Edited<br><br>Edited so i can save it to the database.

  • 2 weeks later...

Save the data as-is to the database. Before printing it to the screen, run the text through the php nl2br() function. When you are putting the data into a textarea, you won't have to do anything, as you save it in its original form in the database, so putting it back in a textarea will make it exactly the same as it was before it was saved.

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.