0

我通过以下方式从 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 获得正确的收据变量。

4

0 回答 0