<?php
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql="select * from message";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){?>
<tr bgcolor="#eff3ff">
<td> 标题: <?=$row[title]?> 用户:<?=$row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?=$row[content]?></td>
</tr>
<?
}
?>
</table>
前面已经建留言板好数据库,并且添加了数据为什么不能调用出来title 和content 还有user的里面的内容?
高手给看看啊
弄了一下午还是不行。来人啊。
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql="select * from message";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){?>
<tr bgcolor="#eff3ff">
<td> 标题: <?=$row[title]?> 用户:<?=$row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?=$row[content]?></td>
</tr>
<?
}
?>
</table>
前面已经建留言板好数据库,并且添加了数据为什么不能调用出来title 和content 还有user的里面的内容?
高手给看看啊
弄了一下午还是不行。来人啊。
先试试$row['title']
<?php
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql="select * from message";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
//试一下,先确认你已成功从数据库里读取数据。
var_dump($row); }
?>
</table>
<?php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>
这是更新留言内容的文件
<?php
include("conn.php");
if($_POST['submit']){
$sql="insert into message (id,user,title,content,lastdate) values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "发表成功";
}?> <form action="add.php" method="post">
用户:<input type="text" size="10" name="user" /></br>
标题:<input type="text" name="title" /></br>
内容:<textarea name="content"></textarea></br> <input type="submit" name="submit" value="发布留言"/>
</form>
根本form里的数据就没写入到数据库中
tail -f log.log
$sql="select * from message";
$query=mysql_query($sql);
while(……
首先 你的写法相当的不规范
注意此处<?=$row[content]?>
改成<?php echo $row[content]?>