为什么用循环语句从数据库里循环输出数据,如果数据库里相应的字段没有付值就输出空白,但为什么对应的表格也没有输出。如图:,怎样才能把表格完整输出。求个位老师帮忙!

解决方案 »

  1.   

    预览结果是代码是
    <?php
        include("conn/conn.php"); //包含conn.php文件
    $select=mysql_query("select * from lt_send limit ".($page-1)*$pagesize.",$pagesize"); //查询数据
    while($row=mysql_fetch_array($select)){ //循环输出查询内容
    ?>      <tr>
            <td height="40"><span class="STYLE1">
              <input name="<?php echo $row[lt_send_id];?>" type="checkbox" value="<?php echo $myrow[tb_send_id];?>" />
            </span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_id];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_subject];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_user];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_date];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_type_distillate];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_type_hotspot];?></span></td>
            </tr>
    <?php
    } //结束循环
    ?>
      

  2.   

    这是全部代码?  没有看到<table>标签。
      

  3.   

    全部代码
    <body>
    <?php
           include("conn/conn.php");
           $sql=mysql_query("select count(*) as total from lt_send ",$conn);
       $info=mysql_fetch_array($sql);
       $total=$info[total];
       if($total==0)
       {
         echo "本站暂无记录!";
       }
       else
       {
           $pagesize=8;
       if ($total<=$pagesize){
          $pagecount=1;

    if(($total%$pagesize)!=0){
       $pagecount=intval($total/$pagesize)+1;

    }else{
       $pagecount=$total/$pagesize;

    }
    if(($_GET[page])==""){
        $page=1;

    }else{
        $page=intval($_GET[page]);

    }
     
               $sql1=mysql_query("select * from lt_send order by lt_send_id desc limit ".($page-1)*$pagesize.",$pagesize",$conn);
    ?><form id="form1" name="form1" method="post" action="bbs_update_ok.php">
    <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="32" background="images/right_line.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您现在的位置:校园馨浪网站后台管理系统 &gt; 帖子管理</td>
      </tr>
      <tr>
        <td height="32" background="images/right_top.gif">&nbsp;</td>
      </tr>
      <tr>
        <td height="488" align="center" valign="top" background="images/right_middle.gif">
    <table width="600" border="1" cellpadding="0" cellspacing="0">
          <tr>
            <td width="140" height="35">选项</td>
            <td width="49">ID</td>
            <td width="58" height="35">贴子主题</td>
            <td width="51" height="35">发布人</td>
            <td width="72" height="35">发布时间</td>
            <td width="105" height="35">精华区</td>
            <td width="109" height="35">热点区</td>
            </tr>
    <?php
        include("conn/conn.php"); //包含conn.php文件
    $select=mysql_query("select * from lt_send limit ".($page-1)*$pagesize.",$pagesize"); //查询数据
    while($row=mysql_fetch_array($select)){ //循环输出查询内容
    ?>      <tr>
            <td height="40"><span class="STYLE1">
              <input name="<?php echo $row[lt_send_id];?>" type="checkbox" value="<?php echo $myrow[tb_send_id];?>" />
            </span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_id];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_subject];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_user];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_date];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_type_distillate];?></span></td>
            <td height="40"><span class="STYLE1"><?php echo $row[lt_send_type_hotspot];?></span></td>
            </tr>
    <?php
    } //结束循环
    ?>
          <tr>
            <td height="40"><input name="button" type="button" class="buttoncss" onclick="checkAll(form1,status)" value="全选" />
              <input name="button" type="button" class="buttoncss" onclick="switchAll(form1,status)" value="反选" />
              <input name="button" type="button" class="buttoncss" onclick="uncheckAll(form1,status)" value="不选" /></td>
            <td height="40" colspan="4">&nbsp;</td>
            <td height="40"><input type="submit" name="Submit" value="精华帖" />
              <input type="submit" name="Submit3" value="取消" /></td>
            <td height="40"><input type="submit" name="Submit2" value="热门帖" />
              <input type="submit" name="Submit4" value="取消" /></td>
          </tr>
        </table>
          <table width="600" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td>本站共有公告
                <?php
       echo $total;
      ?>
    &nbsp;条&nbsp;每页显示&nbsp;<?php echo $pagesize;?>&nbsp;条&nbsp;第&nbsp;<?php echo $page;?>&nbsp;页/共&nbsp;<?php echo $pagecount; ?>&nbsp;页
    <?php
      if($page>=2)
      {
      ?>
    <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=1" title="首页"><font face="webdings"> 9 </font></a> <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=<?php echo $page-1;?>" title="前一页"><font face="webdings"> 7 </font></a>
    <?php
      }
       if($pagecount<=4){
        for($i=1;$i<=$pagecount;$i++){
      ?>
    <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=<?php echo $i;?>"><?php echo $i;?></a>
    <?php
         }
       }else{
       for($i=1;$i<=4;$i++){  
      ?>
    <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=<?php echo $i;?>"><?php echo $i;?></a>
    <?php }?>
    <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=<?php echo $page-1;?>" title="后一页"><font face="webdings"> 8 </font></a> <a href="bbs_update.php?id=<?php echo $id;?>&amp;page=<?php echo $pagecount;?>" title="尾页"><font face="webdings"> : </font></a>
    <?php }?></td>
            </tr>
          </table>      <p>&nbsp;</p></td>
      </tr>
      <tr>
        <td height="32" background="images/right_bottom.gif">&nbsp;</td>
      </tr>
    </table><?php
     }
    ?>
    </form>
    </body>
      

  4.   

    可能是table嵌套有问题。你用firebug看看。
      

  5.   

    $row[lt_send_id],这里面的字段名不需引号?
      

  6.   

    浏览器对表格的解析可能有错误.当你的表格内没有内容的时候可能有些样式不起作用.具体为什么我也不太清楚,你可以对每个为空的值进行替换.或者在表格里面嵌套的PHP中即使为空也输出一个&NBSP来占位.希望我的解答能够帮到你.以前好像也遇到了类似的情况.
      

  7.   

    我想你的while循环 while($row=mysql_fetch_array($select)){  //循环输出查询内容  一开始就报false, 循环中的内容就不会输出吧。  你看看网页的源文件就知道了
      

  8.   

    请老师再帮忙看看,firefox平时没有用过,预览结果本应该是:
    但用firefox预览就变成: