Could someone tell me how to add a new line in a text that I enter in a MySql table?
I tried using the \'\\n\'
in the line I entered with INSERT I
You have to replace \n
with
before inset into database.
$data = str_replace("\n", "
", $data);
In this case in database table you will see
instead of new line.
e.g.
First Line
Second Line
will look like:
First Line
Second Line
Another way to view data with new line. First read data from database. And then replace \n
with
e.g. :
echo $data;
$data = str_replace("\n", "
", $data);
echo "
" . $data;
output:
First Line Second Line
First Line
Second Line
You will find details about function str_replace() here: http://php.net/manual/en/function.str-replace.php