Posted by: manshare | December 12, 2007

Calendar on your site

Waah udeh lama nih nggak ngeblog.
ehmmm………… enaknye ngapain yeh.

Oh iyeh, nih gue mo bagi-bagi sedikit codingan php buat nampilin calendar di situs loh!!!

nih preview-nya
Kalender preview

and the code is below

//————————————-cut here—————————————-//

<?php
// function begin
function build_calendar($month,$year,$day) {
/* Declaring the variables */
// make an enumerator or array to the day’s name
$daysOfWeek = array(‘Su’,’Mo’,’Tu’,’We’,’Th’,’Fr’,’Sa’);

// get the first day of the month,
// returning number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
$firstDayOfMonth = mktime(0,0,0,$month,1,$year); //mktime function(0,0,0,$month,$day,$year), return an unique int

// get number of days i this month
$noDays = date(‘t’,$firstDayOfMonth); //date function( string format ,[int timestamp] )

//getdate function ( [int timestamp] ),return an array of the time given
$dateComponents = getdate($firstDayOfMonth); //getdate function([int timestamp])
/*
Array return by the getdate function
(
[seconds] => xx –>Numeric representation of seconds 0 to 59
[minutes] => xx –>Numeric representation of minutes 0 to 59
[hours] => xx –>Numeric representation of hours 0 to 23
[mday] => xx –>Numeric representation of the day of the month 1 to 31
[wday] => xx –>Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
[mon] => xx –>Numeric representation of a month 1 through 12
[year] => xx –>A full numeric representation of a year, 4 digits Examples: 1999 or 2003
[yday] => xx –>Numeric representation of the day of the year 0 through 365
[weekday] => xx –>A full textual representation of the day of the week Sunday through Saturday
[month] => xx –>A full textual representation of a month, such as January through December
[0] => xxuniquexxx –> like mktime
)
*/

// get the day of week in the time given, look at array return by the getdate above
$dayOfWeek = $dateComponents[‘wday’];

// get the full textual representation of the month in the time given
$monthName = date(‘F’,mktime(0,0,0,$month,1,$year));

/* Computing the previous month. */
if($month == 1)
{
$mn=12;
$yn=$year-1;
} else {
$mn=$month-1;
$yn=$year;
}
$altn = date(‘F’,mktime(0,0,0,$mn,1,$yn));

/* Computing the next month. */
if($month == 12) {
$mn2=1;
$yn2=$year+1;
} else {
$mn2=$month+1;
$yn2=$year;
}
$altn2 = date(‘F’,mktime(0,0,0,$mn2,1,$yn2));

/* Calendar header: next and previous month links */
$calendar = “<table>”;
$calendar .= “<tr><td><a href=calendar.php?m=$mn&y=$yn&d=$day ><</a></td>”;
$calendar .=”<td colspan=5 align=center>$monthName, $year</td>”;
$calendar .=”<td><a href=calendar.php?m=$mn2&y=$yn2&d=$day >></a></td></tr>”;
$calendar .=”<tr>”;

/* Calendar header: Display the days of the week */
foreach($daysOfWeek as $day) {
$calendar .= “<td>$day</td>”;
}
$calendar .= “</tr>”;
$calendar .= “<tr>”;

$currentDay = 1;

// get current date
$datenow = getdate();
$monthnow = $datenow[‘mon’];
$yearnow = $datenow[‘year’];
$daynow = $datenow[‘mday’];

/* Fill in the beginning of the calendar body */
if ($dayOfWeek > 0) {
$calendar .= “<td colspan=’$dayOfWeek’> </td>”;
}

/* Generate the calendar body */
while ($currentDay <= $noDays) {
if ($dayOfWeek == 7) {
$dayOfWeek = 0;
$calendar .= “</tr><tr>”;
}
// check wether the day is today
if($year == $yearnow & $month == $monthnow & $currentDay == $daynow)
$calendar .= “<td style=’font-weight:bold; color:blue’>$currentDay</td>”;
else
$calendar .= “<td>$currentDay</td>”;
$currentDay++;
$dayOfWeek++;
}

/* Filling in the end of the calendar body */
if ($dayOfWeek != 7) {
$remainingDays = 7 – $dayOfWeek;
$calendar .= “<td colspan=’$remainingDays’> </td>”;
}

$calendar .= “</table>”;
return $calendar;
}
// end function

// if month, year and date are set then set it
if (isset($_GET[‘m’]) && isset($_GET[‘y’]) && isset($_GET[‘d’]))
{
$month = $_GET[‘m’];
$year = $_GET[‘y’];
$day = $_GET[‘d’];
} else
{
// if month, year and date aren’t set, then set the date to Now
$dateComponents = getdate();
$month = $dateComponents[‘mon’];
$year = $dateComponents[‘year’];
$day = $dateComponents[‘mday’];
}

echo build_calendar($month,$year,$day);
?>

//————————————-cut here—————————————-//

Nah, klo lo mo nyoba jangan lupa save dulu filenye dan kasih nama “calendar.php” , all in lowercase.
dont use another name, except you now how the code works.

But if you want to change the name of the file, you must change some code.
—->contoh<—-
misalnye loh mo’ kasih nama filenye jadi “filename.php”
1. cari di codingan tulisan
$calendar .= “<tr><td><a href=calendar.php?m=$mn&y=$yn&d=$day ><</a></td>”;
ganti jadi
$calendar .= “<tr><td><a href=filename.php?m=$mn&y=$yn&d=$day ><</a></td>”;

2. cari di codingan tulisan
$calendar .=”<td><a href=calendar.php?m=$mn2&y=$yn2&d=$day >></a></td></tr>”;
ganti jadi
$calendar .=”<td><a href=filename.php?m=$mn2&y=$yn2&d=$day >></a></td></tr>”;

nah abis tuh save deh dengan nama “filename.php”,inga’ inga’ extensionnye harus php.

Klo loh mo coba nih codingan di pc desktop or laptop loh, lo harus nginstal apache servernye terlebih dahulu biar code php-nye bisa di interprete.

nah untuk para master ane mohon maaf nih, ane cuman sekedar nge-share, nggak bermaksud sok ataupun sombong.

aah, udeh dulu ah soalnye udeh abis nih waktunye , nanti mama marah, he he he…
see you.

Posted by: manshare | November 20, 2007

lupa ngasih judul

Ups, postingan ke dua sudah dimulai, let it done……

yup dalam postingan gw yg ke-2 ini, go mo share about facebook,. gue sih tau nih situs dari temen gue (baca: Ari brandon). Katanya nih situs nyaingin friendster. eh setelah gue liat kayaknye menarik juga nih, akhirnye gue coba aje!!!, n gue buat account di situ trus gue login de, yah seperti biasanya lo harus fill out your profiles. nah abis ntuh lo invite deh temen-temen lo yg punya facebook.

nah hal yg menarik buat gue tuh that there are lots of stuff like games n palette yg bisa lo maenin and setting di situ, pokoknye better than friendster.

Nah kebanyakan orang kan, skrg pade gunain friendster buat memperbanyak temen, nyari temen, n nyari yg laennye juga so pasti!!!. Nah buat lo-lo yg mo cari n ngerasain sesuatu yg baru, instead of friendster lo bisa cobain deh tuh makluk yg namanye facebook.

Nah selamat mencoba!!!, see ya.

Posted by: manshare | November 19, 2007

Hello world!(nge-dut version)

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Wah, nih postingan tau-tau muncul pas gue pertama kali bikin blog di wordpress

Iseng-iseng gue ganti aje isinye.

ehm……..tapi gue bingung nih (mode cupu=on), gimane cara ngubah template yg udah gue pilih. gue kan mo ganti gambar-gambar ataupun backgroundnye, biar pas dengan selera pria. Ha ha ha(lol). Gudang garam kalee.

©: 2007, Manshare_31

Categories