I have a big problem displaying line breaks from mysql in my php generated html page.
I tried out
str_replace() and so on...
In my sql database the record is like:
first line second line third line
BUT: There are no
<br>'s in that record.
data.mystring.replace(/\n/g, "<br />") on it, everything works fine!
But now I have to echo that data directly via php. And I don't see any line breaks. NO matter what I try. Any idea?
Here's the script (inserted via an ajax call):
$adress = mysqli_real_escape_string($con, $_POST["adress"]); mysqli_query($con, "INSERT INTO Contact SET Adress = '$adress');
Reading the data of the database on my php page:
mysqli_query($con, "SET NAMES 'utf8'"); $query = mysqli_query($con, "SELECT * FROM Contact"); $dsatz = mysqli_fetch_assoc($query); $newString = $dsatz["Adress"]; echo nl2br($newString);