Reputation: 21
I am saving records like below in my MySQL database:
Name: Hello World Age: 17
Ref. by: Lorem Ipusm Sample: Blood
www.domainname.com
Investigations Results Units N.Ranges
Haemoglobin 14.5 Gms%. {13-18}
you might have got an idea ,i am doing the following:
$data = mysqli_real_escape_string($dbc, nl2br($_POST['data']));
$sql = "INSERT INTO data (Data) VALUES ('$data')";
$exec = mysqli_query($dbc, $sql);
But when I am displaying the output, it removes all the extra whitespaces and shows output like:
Name: Hello World Age: 17
Ref by.: Lorem Ipsum Sample: Blood
www.domainname.com
Investigation Results Units N.Ranges
Haemoglobin 14.5 Gms%. {13-18}
All the alignment is messed up, any way to make what I want work? Thanks in advance.
Upvotes: 0
Views: 89
Reputation:
As Fred-ii mentioned, you can wrap your output in <pre></pre>
tags. HTML by default ignores any spaces past the first in output. See this for more information.
An alternative could also be replacing all spaces with
which will force all the spaces to render out on the page.
Upvotes: 1