0
我從正在發送到mysql數據庫的文本區域發送文本,然後在其他頁面的其他地方顯示。來自mysql數據庫的文本區新行?
例如,如果我輸入:
text
text
text
到文本區域,我簡單地接收
text text text
我明白我需要創建一個新的行一些如何在文字之間,但真的不能確定在去它的路上,因爲它被存儲在MySQL中作爲
text||text||text
<div class="panel-heading">Addservices</div>
<div class="panel-body">
<div class="block">
<form method="POST" action="page.php">
<p>Add service title:</p>
<input type="text" class="form-control" name="servicetitle" value=""><br />
</div><div class="block">
<p>Add service content:</p>
<textarea id="b" type="text" class="form-control" name="servicecontent"></textarea>
</div>
<input class="btn btn-primary btn-md" type="submit">
</form>
</div>
代碼而被從
<?php
$getService = $conn->query("SELECT id, value FROM customerlanding WHERE element = 'service'");
while ($row = $getService->fetch_assoc()) {
$id = $row['id'];
$split = explode("||", $row['value']);
echo'
<div class="col-md-4">
<div class="text-column text-column-centralized tex-column-icon-lg this-animate" data-animate="fadeInLeft">
<div class="text-column-icon">
<span style="background-color:'; echo $result['primarycolour']; echo '"class="fa"></span>
</div>
<h4>';
echo $split[0];
echo '</h4>
<div class="text-column-info">
';
echo $split[1];
echo '
</div>
</div>
</div>';
}
?>
拉。
if(isset($_POST['servicetitle'])){
\t $service = $_POST['servicetitle']."||".$_POST['servicecontent'];
\t $insertservice = $conn->query("INSERT INTO `customer`(`customerid`, `element`, `value`) VALUES ('10','service','$service')");
我們展示您將數據插入到數據庫的方式。 – Spectarion
您很可能已經在數據庫中添加了帶有換行符的文本,只是在您顯示文本時HTML不會解釋換行符。嘗試在輸出上使用'nl2br()'。 – Qirel
謝謝Qirel。 – Eric