In my table there is a column Content with text:
<h2>LAGU</h2><p>Pada minggu ke kota.<br />Naik delman.</p><p>Pak kusir.</p>
This Content column collation is latin_swedish_ci
and type is Text
in the phpMyAdmin table structure.
In my PHP page, after the query - I give it a name $content
HTML:
<?php echo $content ?>
<form action="update.php" method="post" enctype="multipart/form-data">
<div id="div_content">
<label id="label_content">Content</label>
<textarea id="content" name="content" value="<?php echo $content ?>"></textarea>
</div>
</form>
The content did show correctly in the first echo. What is in header tag, shown as a header. What is in paragraph tag shown as a paragraph.
But the second echo (which is inside the textarea box), it doesn't show at all. I'm expecting that the textarea box will show exactly the same like the text from the php table, so in case there is a typo or something - the user can edit it directly inside the textarea box.
I've tried one apostrophe instead of double apostrophe
<textarea id="content" name="content" value='<?php echo $content; ?>'></textarea>
The textarea box still empty.
I've tried also this for the textarea
<textarea id="content" name="content" value='.<?php echo $content ?>.'></textarea>
and this
<textarea id="content" name="content" value="'.<?php echo $content ?>.'"></textarea>
Still empty.
But after I've tried this:
<textarea id="content" name="content" value=<?php echo $content ?>></textarea>
The text area box show like this:
LAGU</h2><p>Pada minggu ke kota.<br />Naik delman.</p><p>Pak kusir.</p>>
It lost the 'h2' tag in the beginning. And at the end it reads the closing '>' for the <textarea .....
But the weirdest thing is, if in the PhpMyAdmin I change the table content column by typing dar der dor (just plain text without any weird character), the textarea box is empty no matter what trick I did in the php page.
FYI, besides $content - I also have $title. In phpMyAdmin table, the title column text is MAMA. I put in the php page like this:
<input type="text" id="title" name="title" value="<?php echo $title ?>">
And the inputbox show MAMA.