Page 1 of 1

Show html code from php string in textarea

Posted: 23 Sep 2016, 08:07
by JanMolendijk
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>

Show html code from php string in textarea

Posted: 23 Sep 2016, 08:50
by Admin
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>

Show html code from php string in textarea

Posted: 23 Sep 2016, 13:45
by JanMolendijk
I tried but the textarea field stays empty
jan-molendijk.16mb.com/Test/Comments.php

Show html code from php string in textarea

Posted: 23 Sep 2016, 13:50
by Admin
There are errors in html code, and no textarea; which means you modified wrong the html code in the php script.

Show html code from php string in textarea

Posted: 23 Sep 2016, 13:57
by JanMolendijk
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>

Show html code from php string in textarea

Posted: 23 Sep 2016, 14:12
by Admin
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.