我写的这个代码 想在里面实现换行和空格 为什么显示不了 求大神教一下啊
<?phpinclude("conn.php");if(isset($_POST['submit'])){$sql="insertintomessage(id,user,...
<?php include("conn.php");
if(isset($_POST['submit'])){
$sql="insert into message (id,user,title,content,lastdate) " .
"values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())"; mysql_query($sql);
echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";}?>
<SCRIPT language=javascript>
function CheckPost()
{ if (myform.user.value=="")
{alert("请填写用户名");
myform.user.focus();
return false;}
if (myform.title.value.length<5)
{alert("标题不能少于5个字符");
myform.title.focus();
return false;}
if (myform.content.value=="")
{alert("必须要填写留言内容");
myform.content.focus();
return false;}}</SCRIPT>
<center><form action="message.php" method="post" name="myform" onsubmit="return CheckPost();">
用户:<input type="text" size="10" name="user" /><br>
标题:<input type="text" name="title" /><br/>
内容:<textarea name="content" cols="60" rows="9"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form></center>
<table width=500 border="0" align="center" cellpadding="5"
cellspacing="1" bgcolor="$add3ef">
<?php function htmtocode($content)
{$Enter=array("\n","<br>");
$nbsp=array(""," ");
return str_replace($Enter, str_replace($nbsp, $content));return $content;}
$sql="select * from message order by id desc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){?> <tr bgcolor="#eff3ff">
<td>标题:<?php echo $row['title'];?> <p align=right>用户: <?php echo $row['user'];?> </p></td> </tr> <tr bgcolor="#ffffff">
<td>内容:<?php echo $row['content'];?></td></tr> <?php } ?> </table>
就是这个位置 那个$nbsp=array(" ","& nbsp");是故意打了个空格的 不然显示不出来
<?php function htmtocode($content)
{$Enter=array("\n","<br>");
$nbsp=array(" ","& nbsp");
return str_replace($Enter, str_replace($nbsp, $content));return $content;}
$sql="select * from message order by id desc";
求解怎么弄才能实现换行和空格 展开
if(isset($_POST['submit'])){
$sql="insert into message (id,user,title,content,lastdate) " .
"values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())"; mysql_query($sql);
echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";}?>
<SCRIPT language=javascript>
function CheckPost()
{ if (myform.user.value=="")
{alert("请填写用户名");
myform.user.focus();
return false;}
if (myform.title.value.length<5)
{alert("标题不能少于5个字符");
myform.title.focus();
return false;}
if (myform.content.value=="")
{alert("必须要填写留言内容");
myform.content.focus();
return false;}}</SCRIPT>
<center><form action="message.php" method="post" name="myform" onsubmit="return CheckPost();">
用户:<input type="text" size="10" name="user" /><br>
标题:<input type="text" name="title" /><br/>
内容:<textarea name="content" cols="60" rows="9"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form></center>
<table width=500 border="0" align="center" cellpadding="5"
cellspacing="1" bgcolor="$add3ef">
<?php function htmtocode($content)
{$Enter=array("\n","<br>");
$nbsp=array(""," ");
return str_replace($Enter, str_replace($nbsp, $content));return $content;}
$sql="select * from message order by id desc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){?> <tr bgcolor="#eff3ff">
<td>标题:<?php echo $row['title'];?> <p align=right>用户: <?php echo $row['user'];?> </p></td> </tr> <tr bgcolor="#ffffff">
<td>内容:<?php echo $row['content'];?></td></tr> <?php } ?> </table>
就是这个位置 那个$nbsp=array(" ","& nbsp");是故意打了个空格的 不然显示不出来
<?php function htmtocode($content)
{$Enter=array("\n","<br>");
$nbsp=array(" ","& nbsp");
return str_replace($Enter, str_replace($nbsp, $content));return $content;}
$sql="select * from message order by id desc";
求解怎么弄才能实现换行和空格 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询