php - HTML Table not recognising line breaks from mysql database -
i have mysql database 'address' field (varchar). have html table used display addresses of different staff members.
my problem data stored in address field of database linebreaks between each line of address, when data displayed in table line breaks not there, entire address displayed on 1 line. how can fix this?
i'm sure question asked time, can't find answer anywhere. i'm new php please forgive naivety.
thanks,
joe
update:
this code:
if(isset($_post['submit'])) { $address = $_post['address']; $queryupdate = "update staff set address= :address id= :id"; $q = $db->prepare($queryupdate); $q->execute(array( ":id" => $id, ":address" => $address));
the data in $address variable taken simple textarea.
actual line breaks never shown in html unless word-wrap
set pre
, or actual pre
tag used. however, overcome can use nl2br()
functionality in php. you'll need use nl2br()
before outputting data browser, , give html formatted string line breaks prepended <br>
tags.
see documentation nl2br()
here: http://php.net/manual/en/function.nl2br.php
Comments
Post a Comment