php中form表單送出保留白格和回車
nl2br
nl2br(string)
本函數将換行字元轉換成 HTML 換行的 <br> 指令。
<a href="http://blog.51cto.com/attachment/201212/180009501.jpg" target="_blank"></a>
<?php
include('conn.php');
if($_POST){
$title=nl2br($_POST['title']);
$sql="insert into `home` (`id`,`username`,`banner_imgurl`) values (NULL,'$title','1')";
mysql_query($sql);
}
?>
<form action="" method="post">
<textarea name="title"></textarea>
<input type="submit" value="送出" />
</form>
$sql="select * from `home`";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo $row['username'];
本文轉自許琴 51CTO部落格,原文連結:http://blog.51cto.com/xuqin/1092302,如需轉載請自行聯系原作者