Ini adalah script untuk membuat tabel berdasarkan sel yang kita inginkan.
Script:
<!DOCTYPE
html>
<html
lang="en">
<head>
<title>Elmiyadi Novia
Farma</title>
</head>
<body>
<?php
function generate_sel($sel, $kolom){
$sisa = $sel%$kolom;
if($sisa != 0){
$tambah = $kolom -
$sisa;
$baris = ($sel/$kolom)+1;
$jumlahstring = $sel +
$tambah;
}
else{
$baris = $sel/$kolom;
$jumlahstring = $sel;
}
for($i=0;
$i<=$jumlahstring+1; $i++){
if($i>$sel-1){
$array_sel[] =
" ";
}
else{
$array_sel[] = $i+1;
}
}
echo '<table border = 1
cellpadding=10>';
if($sisa ==0){
for ($i=1;
$i<$baris+1; $i++){
echo
'<tr>';
for ($j=1;
$j<=$kolom; $j++){
echo
'<td>';
echo
$array_sel[$counter];
$counter++;
echo
'</td>';
}
echo
'</tr>';
}
echo
'</table>';
}
else{
for ($i=1;
$i<$baris; $i++){
echo
'<tr>';
for ($j=1;
$j<=$kolom; $j++){
echo
'<td>';
echo
$array_sel[$counter];
$counter++;
echo
'</td>';
}
echo
'</tr>';
}
echo
'</table>';
}
}
generate_sel(8,4);
?>
</body>
</html>
Tidak ada komentar:
Posting Komentar