其实存到数据库后分段标识是存在的,只需输出的时候处理一下即可!
//$content为数据库中取出的文本
$content=str_replace("\n\r","<br>",$content);
$content=str_replace(" "," ",$content);
$content=nl2br($content);
//$content为数据库中取出的文本
$content=str_replace("\n\r","<br>",$content);
$content=str_replace(" "," ",$content);
$content=nl2br($content);
直接nl2br($content)
就可以了
================================================================
不记酬劳,不畏艰难,不辞辛苦,为了我们心中的绿色
<?php require_once('../../Connections/MyMy2010.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = $_GET['id'];
}
mysql_select_db($database_MyMy2010, $MyMy2010);
$query_Recordset1 = sprintf("SELECT * FROM news WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $MyMy2010) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><html>
<head><title>新闻阅读栏</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../kuaile.css" rel="stylesheet" type="text/css">
</head>
<body >
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#A2C066">
<tr>
<td height="50" colspan="2"><div align="center" class="title12">新闻浏览</div></td>
</tr>
<tr>
<td height="25" bgcolor="#C8E2B1"><span class="content">标题:<?php echo $row_Recordset1['title']; ?></span></td>
<td height="25" bgcolor="#C8E2B1"><span class="content">点击次数: <?php echo $row_Recordset1['hits']; ?></span></td>
</tr>
<tr>
<td height="25" colspan="2" bgcolor="#C8E2B1"><p>新闻内容:</p>
<p><?php echo $row_Recordset1['content'];?></p>
<p></p></td>
</tr>
<tr>
<td height="25" bgcolor="#C8E2B1"><span class="content">作者:<?php echo $row_Recordset1['author']; ?></span></td>
<td height="25" bgcolor="#C8E2B1"><div align="right"><span class="content">发布时间:<?php echo $row_Recordset1['time']; ?></span></div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>