<?php
/*
 * Created on 2010-4-24
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 include("conn.php");?><?php
 echo "<table width=500 border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#add3ef'>";
  $strSQL='select * from message ';
  $query=mysql_query($strSQL);
  while($rowMsg=mysql_fetch_array($query))
 echo "<tr  bgcolor='#eff3ff'>";
 echo "<td>标题:$rowMsg[title] 用户:$rowMsg[userName]</td>";
 echo "</tr><td>内容:$rowMsg[content]</td> </tr> </table>";
 ?>
数据库连接没有问题,就是表格循环输出就数据出来啊???
各位大侠帮忙看下这段代码是否有错???

解决方案 »

  1.   


     $strSQL='select * from message ';
      $query=mysql_query($strSQL);
      while($rowMsg=mysql_fetch_array($query))
    {
     echo "<tr  bgcolor='#eff3ff'>";
     echo "<td>标题:$rowMsg[title] 用户:$rowMsg[userName]</td>";
     echo "</tr><td>内容:$rowMsg[content]</td> </tr> </table>";
    }括号括起来就OK罗。
      

  2.   

    上楼的有点错误,table
    <?php
     echo "<table width=500 border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#add3ef'>";
      $strSQL='select * from message ';
      $query=mysql_query($strSQL);
      while($rowMsg=mysql_fetch_array($query)) {
              echo "<tr  bgcolor='#eff3ff'>";
              echo "<td>标题:$rowMsg[title] 用户:$rowMsg[userName]</td>";
              echo "</tr><td>内容:$rowMsg[content]</td> </tr>";
     }
     echo '</table>'; //这个不包括在循环内
     ?>
      

  3.   


    <?php
    /*
     * Created on 2010-4-22
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
     include("conn.php");
    ?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?php
      $sql="select * from message";
      $query=mysql_query($sql);
      while($row=mysql_fetch_array($query)){
      ?>
      <tr  bgcolor="#eff3ff">
      <td>标题:<?=$row[title]?> 用户:<?=$row[user]."ttttt"?></td>
      </tr>
      <tr bgColor="#ffffff">
      <td>内容:<?=$row[content]?></td>
      </tr>
      <?php
      }
      ?>
      </table>为什么easyEclipse无法解析<?=$row[content]?>
    如果这样写:<?php echo $row[content]?>
    就能出来,各位大侠帮忙看下是什么原因,怎么解决啊???
      

  4.   

    php.ini关才了短标签。。你可以开启但建议使用标准写法 <?php echo $value;?>
      

  5.   

    <?=$row[content]?>这种写法好像java啊 ,呵呵,:<?php echo $row[content]?>php语法的问题
      

  6.   

    php也有<?=?>这种写法,一般服务器默认是关闭了这个功能。