Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        6年前关闭。
                                                                                            
                
        
使用php和mysql在表单元格中显示记录,并有限制。

表格储存格:4,并显示记录内容​​长度5

输出:

1  6   11  16
2  7   12  17    ---------> Row 1
3  8   13  18
4  9   14  19
5  10  15  20

21  26   31  36
22  27   32  37  ---------> Row 2
23  28   33
24  29   34
25  30   35


谁能帮助我使用php在此ormat中显示记录。

谢谢。

最佳答案

尝试这个 :)

<?php
$a = array ("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20");
echo '<table>';
echo '<tr><td>';
$columns = 4;   // how many columns you want.
$break = ceil(count($a)/$columns);
for($i=0;$i<=count($a);$i++)
{
    if($i%$break==0)
    {
        echo "</td><td>";
    }
    echo '<a>'.$a[$i].'</a></br>';
}
echo '</td></tr>';
echo '</table>';
?>

07-24 22:29