GENERATE TABLE

kita akan membuat tabel dengan cara men-generate tabel dari sebuah matriks dengan jumlah sel tertentu





source codenya adalah:

<em><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>Generate Tabel</title>

</head>

<body>

<h3 align="center" class="style1">GENERATE TABEL</h3>

<div align="center">

  <?php

$rows = 1;

$columns = 1;

$cells = 1;

?>

  <?php $rows = 3; ?>

  <?php $columns = 4; ?>

  <?php $cells = 12; ?>

 

  <?php

    echo "<table width=300 height=300 border=1>";

    $baris = 0;

    $sel = 1;

    while ($sel <= $cells)

    {

        while ($baris < $rows)

        {

            echo "<tr>";

            $kolom = 0;

            while ($kolom < $columns)

            {

                if ($sel <= $cells)

                    {

                        echo "<td><div align=center>".$sel."</div></td>";

                        $sel++;

                    }

                $kolom++;

            }

        echo "</tr>";

        $baris++;

        }

    }

    echo "</table>";

?>

</div>

</body>

</html></em>

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

0 Response to "GENERATE TABLE"

Posting Komentar