I tried to get some value populated in textarea but not getting the way I wanted it.
This is what I've done.
I'm getting some value saved in MySQL DB and keep the value in an array. For testing purpose, I'm only using a single record.
$sql_find_draft = "SELECT * FROM `draft` WHERE `id`=46";
$result_find_draft = mysqli_query($conn, $sql_find_draft);
if(mysqli_num_rows($result_find_draft) > 0){
while ($row = mysqli_fetch_array($result_find_draft)) {
$array_draft = array(
"notes" => $row['notes']
);
}
}
$test_note_1 = $array_draft['notes'];
$test_note_2 = "This is line 1\nThis is line 2";
<textarea><?php echo $test_note_1 ?></textarea>
<br>
<br>
<textarea><?php echo $test_note_2 ?></textarea>
This is what I get when I do a print_r
. Which is exactly how I stored it in MySQL
Array ( [notes] => This is line 1\nThis is line 2 )
So, why do I get different results on $test_note_1
and $test_note_2
on textarea like this?
https://i.ibb.co/pwGLRjN/textarea.png
I want textarea to be displaying the content like textarea2. Even both strings are the same. Please advise.
Update:
I've fixed this with the following:
$test_note_1 = stripcslashes($array_draft['notes']);
I've fixed this with the following:
$test_note_1 = stripcslashes($array_draft['notes']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.