Membuat kalender sederhana dengan PHP

Desember 28, 2007 at 8:22 pm 2 komentar

Wah ketemu lagi ma PHP ni. Okeh langsung aja yah, dari percobaan ku ni scriptnya; Coba ndiri klo ndak percaya, klo ndak isa silahkan protes di commentnya okeh;

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>&lt;?php
define(“ADAY”, (60*60*24));
if                 (!checkdate($_POST[‘month’],     1,
$_POST[‘year’])) {
$nowarray = getdate();
$month = $nowarray[‘mon’];
$year = $nowarray[‘year’];
} else {
$month = $_POST[‘month’];
$year = $_POST[‘year’];
}
$start = mktime (12, 0, 0, $month, 1, $year);
$firstdayarray = getdate($start);
?>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title><?php print “Kalender : “.$firstdayarray[‘month’].”
“.$firstdayarray[‘year’] ?></title>
</head>

<body>
<h1>Kalender Online</h1>
<form method=”post” action=”<?php print “$_SERVER[PHP_SELF]”; ?>”>
<select name=”month”>
<?php
$months = array(“Januari”, “Februari”, “Maret”, “April”, “Mei”, “Juni”, “Agustus”, “September”, “Oktober”, “November”, “Desember”);
for ($x=1; $x <= count($months); $x++) {
print “<option value=\”$x\””;
if ($x == $month) {
print “SELECTED”;
}
print “>”.$months[$x-1].””;
}
?>
</select>
<select name=”year”>
<?php

for ($x=1980; $x<=2010; $x++) {
print “<option”;
if ($x == $year) {
print ” SELECTED”;
}
print “>$x”;
}
?>
</select>
</form>
<br />
<?php
$days = array(“Minggu”, “Senin”, “Selasa”, “Rabu”, “Kamis”, “Jumat”, “Sabtu”);
print “<h1>$firstdayarray[year]</h1>”;
print “<h3>$firstdayarray[month]</h3>”;
print “<table border=1 cellpadding=5><tr>\n”; foreach ($days as $day) {
if ($day == “Minggu”) {
print “<td bgcolor=\”#FF0000\”

align=center><strong>$day</strong></td>\n”;
}
else {
print “<td bgcolor=\”#CCCCCC\”
align=center><strong>$day</strong></td>\n”;
}
}
for ($count=0; $count < (6*7); $count++) {
$dayarray = getdate ($start);
if (($count % 7) == 0) {
if ($dayarray[‘mon’] !== $month) {
break;
} else {
print “</tr><tr>\n”;
}
}
if ($count < $firstdayarray[‘wday’] ||
$dayarray[‘mon’] != $month) {
print “<td>&nbsp;</td>\n”;
} else {
print “<td><font
color=\”0000FF\”>”.$dayarray[‘mday’].”
</font>&nbsp;&nbsp; </td>\n”;
$start += ADAY;
}
}
print “</tr></table>”;
?>
</body>
</html>

Slamat mencoba yah

Entry filed under: Teknologi. Tags: .

Membuat hit counter sederhana Download PC MAV RC-23

2 Komentar Add your own

  • 1. afry  |  Maret 14, 2008 pukul 6:17 pm

    z coba dulu yach script php_Nya,,
    yang untuk buat tanggal,,
    thank,,

    aaaaaawwwwwaaaaaaaaaaaaaassssssssssssss…………….. yaaaaaaaccccccccchhhhhhhhh………..
    kalau ndak bisa z hancurin web/blog_mu ini…..

    key bro,,

  • 2. borix69  |  April 6, 2008 pukul 5:08 am

    wah wah
    ya jangn gitu to bro!
    kjamnya dunia
    gimana?
    isa gak?

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Kalender

Desember 2007
S S R K J S M
    Jan »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Pos-pos Terbaru

A soup for Our Soul

My Chat’s


%d blogger menyukai ini: