<?PHP
header("Content-Type:text/html;charset=UTF-8"); session_start();
include_once("function_db.php");
$link = connect_db(); $sql = "select * from message where isclearing = '已解决' order by M_time desc";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
?>          
<TABLE cellSpacing=6 cellPadding=0 width=700>
  <TBODY> 
  <TR>
    <TH width=43>&nbsp;</TH>
    <TD colspan="2" align="right"><input type="text" name="title1" />
      <label>
      <input type="submit" name="Submit" value="提交" />
      </label></TD>
  </TR>
  <TR>
    <TH style="VERTICAL-ALIGN: top">&nbsp;</TH>
    <TD width="531"><?=$row[M_title]?></TD>
    <TD width="100"><?=$row[M_time]?></TD>
  </TR>
  <tr>
   <td colspan="3"><?=$row[M_content]?></td>
  </tr>
  <tr>
   <td colspan="3"><?=$row[ revert_message]?></td>
  </tr>
</TBODY></TABLE>
<?
}
?>为什么我这样写了以后页面什么都没有啊

解决方案 »

  1.   

    while($row=mysql_fetch_array($query))
    你这样写,当这边查询没值的时候  就一片空白了。
      

  2.   

    你寫的代碼沒有錯,頁面什麼都沒有,可能是以下問題引起的:
    查詢數據庫沒有內容,所以進不了while循環
    你直接在數據庫執行select * from message where isclearing = '已解决' order by M_time desc 看下有沒有記錄
      

  3.   

    <?=$row[M_title]?> 这个要用的话 要打开配置文件的一个开关,你看看asp_tags有没有打开。如果不想打开可以这样用:<?php echo $row[M_title]?> 还有这里 
    <? 

    ?> 最好改成<?php }?>
      

  4.   

    用下面这代码看看(主要是不知道你要显示啥效果)
    <?PHP 
    header("Content-Type:text/html;charset=UTF-8"); session_start(); 
    include_once("function_db.php"); 
    ?>
    <TABLE cellSpacing=6 cellPadding=0 width=700> 
      <TBODY> 
      <TR> 
        <TH width=43>&nbsp; </TH> 
        <TD colspan="2" align="right"> <input type="text" name="title1" /> 
          <label> 
          <input type="submit" name="Submit" value="提交" /> 
          </label> </TD> 
      </TR> 
    <?php
    $link = connect_db(); $sql = "select * from message where isclearing = '已解决' order by M_time desc"; 
    $query = mysql_query($sql); 
    while($row=mysql_fetch_array($query)){ 
    ?>
    <TR> 
        <TH style="VERTICAL-ALIGN: top">&nbsp; </TH> 
        <TD width="531"> <?=$row[M_title]?> </TD> 
        <TD width="100"> <?=$row[M_time]?> </TD> 
      </TR> 
      <tr> 
      <td colspan="3"> <?=$row[M_content]?> </td> 
      </tr> 
      <tr> 
      <td colspan="3"> <?=$row[ revert_message]?> </td> 
      </tr> 
    <?php

    ?> 
    </TBODY> </TABLE> 
      

  5.   

    这代码是在 html 里面写  php的吧.
    如果是的话:
    $sql = "select * from message where isclearing = '已解决' order by M_time desc"; 
    这个没值的情况下,
    按照我在4楼写的代码,起码会显示
    <input type="text" name="title1" /> 
          <label> 
          <input type="submit" name="Submit" value="提交" /> 
    </label>
    一个 输入框和提交按钮的.
    如果有值的话
    下面还有你要显示的内容的.
      

  6.   

    那你把代码改成我下面这样:
    <?PHP 
    header("Content-Type:text/html;charset=UTF-8"); session_start(); 
    include_once("function_db.php"); 
    ?> 
    <TABLE cellSpacing=6 cellPadding=0 width=700> 
      <TBODY> 
      <TR> 
        <TH width=43>&nbsp; </TH> 
        <TD colspan="2" align="right"> <input type="text" name="title1" /> 
          <label> 
          <input type="submit" name="Submit" value="提交" /> 
          </label> </TD> 
      </TR> 
    <?php 
    $link = connect_db(); $sql = "select * from message where isclearing = '已解决' order by M_time desc"; 
    $query = mysql_query($sql); 
    while($row=mysql_fetch_array($query)){ 
    ?> 
    <TR> 
        <TH style="VERTICAL-ALIGN: top">&nbsp; </TH> 
        <TD width="531"> <?php echo $row['M_title']; ?> </TD> 
        <TD width="100"> <?php echo $row['M_time]'; ?> </TD> 
      </TR> 
      <tr> 
      <td colspan="3"> <?php echo $row['M_content']; ?> </td> 
      </tr> 
      <tr> 
      <td colspan="3"> <?php echo $row['revert_message']; ?> </td> 
      </tr> 
    <?php 

    ?> 
    </TBODY> </TABLE> 
      

  7.   

    <?=?>这种格式的没试过
    <?php   ?>用这种格式 要想输出字符,用 echo来输出.
    好久没裸写了。.....有点别扭
      

  8.   

    这个跑的起来不?<?PHP
    header("Content-Type:text/html;charset=UTF-8");session_start();
    include_once("function_db.php");
    $link = connect_db();$sql = "select * from message where isclearing = '已解决' order by M_time desc";
    $query = mysql_query($sql);
    while($row=mysql_fetch_array($query)){
    ?>         
    <TABLE cellSpacing=6 cellPadding=0 width=700>
      <TBODY>
      <TR>
        <TH width=43>&nbsp; </TH>
        <TD colspan="2" align="right"> <input type="text" name="title1" />
          <label>
          <input type="submit" name="Submit" value="提交" />
          </label> </TD>
      </TR>
      <TR>
        <TH style="VERTICAL-ALIGN: top">&nbsp; </TH>
        <TD width="531"> <?php echo $row['M_title']?> </TD>
        <TD width="100"> <?php echo $row['M_time']?> </TD>
      </TR>
      <tr>
      <td colspan="3"> <?php echo $row['M_content']?> </td>
      </tr>
      <tr>
      <td colspan="3"> <?php echo $row['revert_message']?> </td>
      </tr>
    </TBODY> </TABLE>
    <?php
    }
    ?>
      

  9.   

    直接在数据库里跑的起来。。会不会和中文编码有关系,php对中文支持不是太好。不过这方面我也不太了解。
      

  10.   

    你在while下面写个echo ‘xx’之类的看看,看看是不是连while循环都没能进去
      

  11.   

    while之前输出下行数看看
    echo mysql_num_rows($query);
      

  12.   

    试着用echo  排错看哪里出错了!
      

  13.   

    页面什么都没有的话就是说是数据库查询没有结果。那如果sql语句没错,并且在mysql命令行里能得到结果的话。那就是编码问题了了。
      

  14.   

    <?=$row[M_title]?>,,<? }?> 个人认为是个不好的习惯
      

  15.   

    我的值为什么取不出来啊,
    echo mysql_num_rows($query);取出来的值是0啊
    但是我在数据库里有匹配的数据啊。
      

  16.   

    $sql = "select * from message where isclearing = '已解决' order by M_time desc"; 
    可以猜到isclearing 字段是一判断标识,竟然存入中文,lz....
    你大可以存入个数字,比如1,代表未解决,2就代表已解决.把1,2读到页面再做处理.为什么这样的字段也要在数据库里存中文呢?
    try
    ====================
    $sql = "select * from message where isclearing = binary '已解决' order by M_time desc"; 
      

  17.   

    进步是需要代价的,慢慢来。echo echo echo ......肯定可以找出问题的
      

  18.   

    问题可能不在这儿,确保你的文件是utf的另外,最后也 mysql_query("set names 'utf8')下
      

  19.   

    新建一个文件,把下面的代码放进去运行一下,看看有没有数据。
    <?PHP 
    include_once("function_db.php"); 
    $link = connect_db(); 
    $sql = "select * from message where isclearing = '已解决' order by M_time desc"; //要保证这条语句执行的时候有数据产生
    $query = mysql_query($sql); 
    while($row=mysql_fetch_array($query)){ 
        print_r($row);

    ?>
    如果有数据的话,就再把那个表格内容放进去就行了。
      

  20.   

    如果php配置不是你配的,或是对这方面不太了解。建议把<?=$row[M_title]?>改为<?php echo $row['M_title']?>试试。