Senin, 02 Desember 2013

Membuat Table Berwarna di Website

<?php
                    $baris= 1;
                    echo "<table width=\"500\" border=\"7\" cellpadding=\"10\" cellspacing=\"1\" bgcolor=\"#ffffff\">";
                    echo "<tr bgcolor=\"#00CC00\">";
                    echo "<th>No.</th>";
                    echo "<th>Nama</th>";
                    echo "<th>Alamat</th>";
                    echo "</tr>";
                    for($i=1; $i<=10;$i++) {
                    $warna= ($baris% 2 == 1) ? "#cccccc" : "#99FF99";
                    echo "<tr bgcolor=\"".$warna."\">";
                    echo "<td>$i</td>";
                    echo "<td>Nama $i</td>";
                    echo "<td>Alamat $i</td>";
                    echo "</tr>";
                    $baris++;
                    }
                    echo "</table>";
                ?>

Tidak ada komentar:

Posting Komentar