<?php
/*
 * Created on 2010-9-6
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
include ("dblink.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>内容:<?php echo $row[content];?></td>
  </tr>
  <?
}
  ?>
</table>大家帮忙看一下  为什么从数据库中  没有读出数据!!!  谢谢啦!!!

解决方案 »

  1.   

    可能性太多,你检查数据连接成功了吗?有没有错误信息
    这个SQL语句放在数据库中有输出数据吗?
      

  2.   

    $row=mysql_fetch_array($query)
    改成:
    $row=mysql_fetch_assoc($query) 或者 $row=mysql_fetch_array($query, MYSQL_ASSOC)程序后面
    <td>标题:<?=$row[title];?> 用户:<?=$row[user]?></td>
      

  3.   

    看表里有没有数据
     用$row= mysql_fetch_object($result);
    $row->username;读取数据
    你可以先查询出来结果总数看有多少行数据
    select count(*)...
    $row[0];看下有没有数据 $row["username"]读取数据加上双引号 另外最好用htmlentities()转换下
      

  4.   

    http://www.111cn.net/phper/21/f8afbd098f7da5ff31c90a6150694fc0.htm
    这文章适合你
      

  5.   

    浏览器上查看源代码,如果看到 php 代码,则表示你的 php 不支持短标记
    将独立的 <? 改成 <?php 即可
      

  6.   

    <?php
    /*
     * Created on 2010-9-6
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
    include ("include.php");
    ?>
    <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?php
        $sql="select * from xin";
        $query=mysql_query($sql) or die(mysql_error());
        while($row=mysql_fetch_array($query)){
    $a=$row[id];
    $b=$row[name];
    $c=$row[content];
    ?>
      <tr bgcolor="#eff3ff">
      <td>标题:<?php echo $a;?> 用户:<?php echo $b?></td>
      </tr>
      <tr bgColor="#ffffff">
      <td>内容:<?php echo $c;?></td>
      </tr>
      <?php
        }
      ?>
    </table>
      

  7.   

    先看下有没有数据吧,然后在研究显示数据,多看api吧
      

  8.   

    运行出来了
    你把对应的内容改成你的就可以了
    主要是<?的问题,要<?php
    在混合html的标记里面 一定要写php
      

  9.   

    <td>标题:<?=$row[title];?> 用户:<?=$row[user]?></td>
    应该少了单引号试一下
    <td>标题:<?=$row['title'];?> 用户:<?=$row['user']?></td>
      

  10.   

    直接用<? echo $row[title];?> 输出变量试试!