在线表?
你可以显示的时候取模如果$i%7==0
输出<br>或者<tr>

解决方案 »

  1.   

    我做了这个,你看看符合你的要求吗?改改就好了。数组你可以从数据库里边查,整理出来就可以了。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <table width="600" height="98" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr> 
        <td colspan="4">
        <div align="center">在线用户列表</div></td>
      </tr>
    <?$alluser=array();
    $alluser[]="111";
    $alluser[]="222";
    $alluser[]="333";
    $alluser[]="444";
    $alluser[]="555";
    $alluser[]="666";
    $alluser[]="777";
    //给数组赋值$num=count($alluser);
    //求出数组中元素的个数$per_row=4;
    //假设每行显示4个$row=ceil($num/$per_row);
    //计算要循环的次数,也就是打印的行数for($i=0;$i<$row;$i++)
    {?> 
      <tr>  
     <?for($j=0;$j<$per_row;$j++)
     {?>
     
        <td><?=$alluser[($i*$per_row+$j)]?></td> 
      
      <?}?>
     </tr> 
     
    <?}?>
    </table>
    </body>
    </html>