<?$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("newdb", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;//=================================?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql_str="select * from message";
$query=mysql_query($sql_str,$conn);
while($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>标题:<?=row[title]?> 用户:<?=row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?=row[coontent]?> </td>
</tr>
<?
}
?>
</table>以上的代码能够正常运行,并且记录数量也正确。
但是,“标题”、“用户”和“内容”中的内容却无法正常显示。
请高手指点,问题出在什么地方?谢谢!
mysql_select_db("newdb", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;//=================================?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql_str="select * from message";
$query=mysql_query($sql_str,$conn);
while($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>标题:<?=row[title]?> 用户:<?=row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?=row[coontent]?> </td>
</tr>
<?
}
?>
</table>以上的代码能够正常运行,并且记录数量也正确。
但是,“标题”、“用户”和“内容”中的内容却无法正常显示。
请高手指点,问题出在什么地方?谢谢!
<td>标题: <?=row[title]?> 用户: <?=$row[user]?> </td>
</tr>
<tr bgColor="#ffffff">
<td>内容: <?=$row[coontent]?> </td>
</tr>
<tr bgColor="#ffffff">
<td>内容: <?=$row[coontent]?> </td>
刚才写错了的确有$,但是不能显示title、user、content的内容
不知道为什么?不放在<td></td>中显示没问题,但是放在<td></td>中就显示不对了
<?=$row["title"]?> 加个$ 字段两边加""
但是好像看到很多程序都是使用<?= ?>的办法做的,为什么我的就不行呢?郁闷!
<?= ?>这种写法很不严谨,不建议。