<?php
$db=mysql_connect("localhost","root","dirdir");
mysql_select_db("wyx",$db);
mysql_query("set names 'gb2312'");
$SQL="select * from wyx_class order by wyx_classsort asc";
$Result=mysql_query($SQL);
if($Result)
    {
        //循环显示所有的栏目
        while($Row=mysql_fetch_array($Result))
        {
            $wyx_classid=$Row["wyx_id"];
            $wyx_classname=$Row["wyx_classname"];
?> 
 <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr bgcolor="#93C8D2">
                          <td height="28" colspan="2" bgcolor="#E7E7E7" style="color: #000000; font-size: 14px; text-align: left;">
                              &nbsp;◎&nbsp;<?php echo $wyx_classname ?> 
                          </td>
                          <td align="right" valign="middle" bgcolor="#CCCCCC" style="width: 123px">
                              <div align="center">
                                  <span style="color: #000000"><a href="list.php?id=<?php echo $wyx_classid ?>" target="_blank">更多</a></span></div>
                          </td>
                      </tr>
    <?php 
    //显示栏目对应的文章
    $sql="SELECT * FROM wyx_text WHERE wyx_class=$wyx_classid";
    $conn=mysql_query($sql);
    $rs=mysql_fetch_array($conn); //不要用while 了
    ?>    
                      <tr bgcolor="#FFFFFF">    
                          <td colspan="2" height="21" style="text-align: left"><img src="images/wyx_1.gif" width="10" height="10">     <?=$rs[wyx_title]?>                      
                            </td>
                          <td align="center" style="font-size: 14px; width: 123px;" height="21">[]
                            </td>                            
                          </td>                      
      </tr>
                  </table><br/>
<?php
}
}
?>

解决方案 »

  1.   


    <?php
    $db=mysql_connect("localhost","root","dirdir");
    mysql_select_db("wyx",$db);
    mysql_query("set names 'gb2312'");
    $SQL="select * from wyx_class order by wyx_classsort asc";
    $Result=mysql_query($SQL);
    if($Result)
        {
            //循环显示所有的栏目
            while($Row=mysql_fetch_array($Result))
            {
                $wyx_classid=$Row["wyx_id"];
                $wyx_classname=$Row["wyx_classname"];
    ?> 
     <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr bgcolor="#93C8D2">
                              <td height="28" colspan="2" bgcolor="#E7E7E7" style="color: #000000; font-size: 14px; text-align: left;">
                                  &nbsp;◎&nbsp;<?php echo $wyx_classname ?> 
                              </td>
                              <td align="right" valign="middle" bgcolor="#CCCCCC" style="width: 123px">
                                  <div align="center">
                                      <span style="color: #000000"><a href="list.php?id=<?php echo $wyx_classid ?>" target="_blank">更多</a></span></div>
                              </td>
                          </tr>
        <?php 
        //显示栏目对应的文章
        $sql="SELECT * FROM wyx_text WHERE wyx_class=$wyx_classid";
        $conn=mysql_query($sql);
        while($rs=mysql_fetch_array($conn))   //这里的循环是要显示的所有文章?,这里用个WHILE,你用了,好像用的不对
       {  
        ?>    
                          <tr bgcolor="#FFFFFF">    
                              <td colspan="2" height="21" style="text-align: left"><img src="images/wyx_1.gif" width="10" height="10">     <?=$rs[wyx_title]?>                      
                                </td>
                              <td align="center" style="font-size: 14px; width: 123px;" height="21">[]
                                </td>                            
                              </td>                      
          </tr>
                      </table><br/>
    <?php
    }
    }
    }
    ?>
      

  2.   


    <?php
    $db=mysql_connect("localhost","root","dirdir");
    mysql_select_db("wyx",$db);
    mysql_query("set names 'gb2312'");
    $SQL="select * from wyx_class order by wyx_classsort asc";
    $Result=mysql_query($SQL);
    if($Result)
        {
            //循环显示所有的栏目
            while($Row=mysql_fetch_array($Result))
            {
                $wyx_classid=$Row["wyx_id"];
                $wyx_classname=$Row["wyx_classname"];
    ?> 
     <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr bgcolor="#93C8D2">
                              <td height="28" colspan="2" bgcolor="#E7E7E7" style="color: #000000; font-size: 14px; text-align: left;">
                                  &nbsp;◎&nbsp;<?php echo $wyx_classname ?> 
                              </td>
                              <td align="right" valign="middle" bgcolor="#CCCCCC" style="width: 123px">
                                  <div align="center">
                                      <span style="color: #000000"><a href="list.php?id=<?php echo $wyx_classid ?>" target="_blank">更多</a></span></div>
                              </td>
                          </tr>
        <?php 
        //显示栏目对应的文章
        $sql="SELECT * FROM wyx_text WHERE wyx_class=$wyx_classid";
        $conn=mysql_query($sql);
        while($rs=mysql_fetch_array($conn))   //这里的循环是要显示的所有文章?,这里用个WHILE,你用了,好像用的不对
       {  
        ?>    
                          <tr bgcolor="#FFFFFF">    
                              <td colspan="2" height="21" style="text-align: left"><img src="images/wyx_1.gif" width="10" height="10">     <?=$rs[wyx_title]?>                      
                                </td>
                              <td align="center" style="font-size: 14px; width: 123px;" height="21">[]
                                </td>                            
                              </td>                      
          </tr>
                     
    <?php
    }
    ?>
     </table><br/> //这里应该改成这样
    <?php
    }
    }
    ?>
      

  3.   


    <?php
    $db=mysql_connect("localhost","root","dirdir");
    mysql_select_db("wyx",$db);
    mysql_query("set names 'gb2312'");
    $SQL="select * from wyx_class order by wyx_classsort asc";
    $Result=mysql_query($SQL);
    if($Result)
    {
    //循环显示所有的栏目
    while($Row=mysql_fetch_array($Result))
    {
    $wyx_classid=$Row["wyx_id"];
    $wyx_classname=$Row["wyx_classname"];
    ?> 
    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr bgcolor="#93C8D2">
            <td height="28" colspan="2" bgcolor="#E7E7E7" style="color: #000000; font-size: 14px; text-align: left;">
                &nbsp;◎&nbsp;<?php echo $wyx_classname ?> 
            </td>
            <td align="right" valign="middle" bgcolor="#CCCCCC" style="width: 123px">
                <div align="center">
                <span style="color: #000000"><a href="list.php?id=<?php echo $wyx_classid ?>" target="_blank">更多</a></span></div>
            </td>
        </tr>
    <?php 
    //显示栏目对应的文章
    $sql="SELECT * FROM wyx_text WHERE wyx_class=$wyx_classid";
    $conn=mysql_query($sql);
    while($rs=mysql_fetch_array($conn));
    {
    ?>    
     <tr bgcolor="#FFFFFF">    
            <td colspan="2" height="21" style="text-align: left"><img src="images/wyx_1.gif" width="10" height="10">     <?=$rs[wyx_title]?>                      
              </td>
            <td align="center" style="font-size: 14px; width: 123px;" height="21">[]
              </td>                            
            </td>                      
    </tr>
    <?php
       } 
      ?>
    </table><br/>
    <?php
    }
    }
    ?>