Show html code from php string in textarea

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts: 282
Location: Holland Rotterdam

Show html code from php string in textarea

I wanna add text into an textarea where i have html code into the title but it does not show the whole html code into the textarea.

Code: Select all

Title: <textarea required name="title"  rows="7" value="'. $row[title] .'"></textarea><br>

Admin Posts: 805
If you want to show the html code as it is in string, apply the htmlentities() function to the string with html code.

Code: Select all

Title: <textarea required name="title"  rows="7">'. htmlentities($row[title]) .'</textarea><br>

JanMolendijk Posts: 282
I tried but the textarea field stays empty
jan-molendijk.16mb.com/Test/Comments.php

Admin Posts: 805
There are errors in html code, and no textarea; which means you modified wrong the html code in the php script.

JanMolendijk Posts: 282
Now i did this but still nothing

Code: Select all

Title: <textarea required name="title" rows="7" value="'. htmlentities($row[title]) .'  ENT_QUOTES, UTF-8"></textarea>

Admin Posts: 805
In <textarea> you not have to add data in "value" attribute, but between starting and ending tags.
Try simple like this:

Code: Select all

Title: <textarea required name="title"  rows="7">'. htmlentities($row[title]) .'</textarea><br>
- If textarea is not show in html page code, the problem is also in another part of the php code where you modified.

Similar Topics