Reputation: 21
I have given input into database from textarea by MySQL.In that textarea i had typed carriage return few times. Whenever i am trying to extract that data from database, a simple line is shown how can i get the data or text as i given input with the carriage returns?
$query2 = new Bin_Query();
$sql2="select * from `product_table` where product_id='".$_GET['product_id']."'";
if($query2->executeQuery($sql2))
$product_records = $query2->records;
$output['product_details']=$product_records[0]['product_details'];
that's how i retrieved the data.
Upvotes: 1
Views: 1525
Reputation: 8094
You have to use nl2br(), check out this about more http://php.net/manual/en/function.nl2br.php actually, the correct way to use nl2br() is not to use it at all when you store your data - it's when you read from the database and are about to output it to the client. Data should not be formatted when inserted to the database, what if you later on want to create a REST-service and you really needed those newlines instead of a HTML-element? May be this help you.
Upvotes: 1