我通过以下方式从PHP创建数据库条目。
<?php
$receipt = "XXX XXX Solutions " . "\n";
$receipt = $receipt . " YYY DELHI " . "\n";
$receipt = $receipt . "TxnId:-" . $txn_id . "\n";
$receipt = $receipt . "Order Time: " . date("H:i:s") . "\n";
$receipt = $receipt . "Date: " . date("d/m/Y") . "\n";
$receipt = $receipt . "ItemDetails:" . "\n";
$receipt = $receipt . "" . "\n";
$sql = sprintf("INSERT INTO cust_orders (session_id,txn_id,status,order_items,delivery,amount,customer_num,del_address, landmark, location, timeslot, dateslot, order_type, receipts) VALUES('%s','%s','PD','%s','HD','%s','%s','%s','%s', '%s', '%s', '%s', '%s', '%s')",$session_id, $txn_id, $order_items_trimmed, $total, $mobilenumber, $address, $landmark, $location, $timeslot, $dateslot, $order_type, $receipt);
$result = mysql_query($sql) or die(mysql_error());
?>
我看到使用新行字符正确创建了数据库条目。 但是,当我检索收据时,我得到一条没有'\ n'的连续线。
$sql = sprintf("SELECT receipts FROM cust_orders");
如何使用\ n获取正确的收据变量。