php 遍历数据表数据并列表横向排列的代码


<?php
$a = array (1,2,3,4,5,6,7,8,9,10,11);
$i = 0;
?>
<table border=1>
<tr>
<?
foreach ($a as $k){
if($i%3==0) {//该处表示需要横向排列的列数.
echo "</tr><tr>";
}
echo "<td>",$k,"</td>";//该处显示该列的数据.
$i ++;
}
?>
</tr>
</table>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/482ac2ce30b022f644c505db6396f7e4.html