我想显示数组数据,条件是每行包含8列,所以第9列是下一行。
?php
include("config.php");
$query=mysql_query("select * from kunci order by id_kunci asc");
$total_kunci=mysql_num_rows($query);
if(mysql_num_rows($query) ==0)
{
$show_kunci="<tr><td colspan='3'>Saat ini belum ada <b>Kunci</b> yang terdaftar!! </td></tr>";
}
else {
$no=0;
while($row=mysql_fetch_assoc($query))
{
$no++;
$label_kunci=$row['label_kunci'];
$id_kunci=$row['id_kunci'];
$show_kunci.="
$id_kunci
";
}
}
?>
<table border="1">
<tr>
<?php
echo "Jumlah_Kunci = ".$total_kunci."<br/>";
$baris=$total_kunci/15;
$sisa=$total_kunci%15;
echo "Hasil Jumlah_Kunci : 15 = ".(int)$baris."<br/>";
echo "Sisa dari pembagian =".$sisa."<br/>";
if($sisa<15)
{
$baris=$baris+1;
}
else
{
$baris=$baris+0;
}
echo "Jumlah baris yang akan tercetak = ".(int)$baris."<br/>"."<br/>";
$a=1;
for($i=1;$i<=$baris;$i++)
{
for($n=1;$n<=8;$n++)
{
//echo $a." | ";
echo $show_kunci[$a]." | ";
$a++;
}
echo "<br/>";
}
?>
</tr>
但是上面的脚本显示: https://i.stack.imgur.com/PBeTf.jpg
应如下所示: https://i.stack.imgur.com/jzzeq.jpg
对于记录表键,请查看:
https://i.stack.imgur.com/wWTg0.jpg
任何人,你能帮助我吗?