在循环外先定义个$i
$i = 1;
while ($row = mysql_fetch_array($query)){
   if ($i%3 != 0)
      echo $row['field']." ";
   else
      echo $row['field']."<br>";
   $i++;
}

解决方案 »

  1.   

    <?php
                include_once "./manage/connect.php";
                $query_s="select atid,atname,atparent from article_type where atparent='0'";
               
               $i = 1;
    while ($row = mysql_fetch_array($query)){
       if ($i%3 != 0)
          echo $row['field']."&nbsp;";
       else
          echo $row['field']."<br>";
       $i++;
    }            echo "
    <table align='top'   border='0' cellspacing='0' cellpadding='0' align='center'>
    <tr>
                
      <td  class='a12b' >&nbsp;{$row_s[atname]}</td></tr>
    </table>
    ";
               
                }
                ?>这样写对不对 怎么不显示 错在哪里
      

  2.   

    该过之后 
     <?php
                include_once "./manage/connect.php";
                $query_s="select atid,atname,atparent from article_type where atparent='0'";
               
             $i = 1;
    while ($row = mysql_fetch_array($query)){
       if ($i%3 != 0)
          echo $row['atname']."&nbsp;";
       else
          echo $row['atname']."<br>";
       $i++;
    }            
                ?>不显示
      

  3.   

    你上面的是$query_s,我那里写的是$query
    当然不会显示拉
      

  4.   

    <?php
       include_once "./manage/connect.php";
       $query_s="select atid,atname,atparent from article_type where atparent='0'";
       $i = 1; 
       while ($row = mysql_fetch_array($query_s)){
          if ($i%3 != 0)
              echo $row['field']."&nbsp;";
           else
              echo $row['field']."<br>";
          $i++;
        }
        echo "
          <table align='top'   border='0' cellspacing='0' cellpadding='0' align='center'>
             <tr>
                 <td  class='a12b' >
                   <?php echo $row_s[atname]?>
                 </td>
            </tr>
        </table>
       ";   ?>