Tanya error kalender

Ikram Shabri · Dec 28, 2012
Misi bli..

mau nanya ane mau bikin kalender agenda, cari di internet dpt dr web
http://www.phpjabbers.com/how-to-make-a-php-calendar-php26.html
Sudah sy ikuti petunjuknya, tp ketika ditampilkan dibawah kolom previous dan next muncul huruf 'n' yang banyak y ?

ini kode php-nya...
<?php
include "../incl_db.php";
?>    
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Agenda</title>
    </head>  
    <body>
    <?php
    $monthNames = Array("January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December");
    ?>
    <?php
    if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
    if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
    ?>
    <?php
    $cMonth = $_REQUEST["month"];
    $cYear = $_REQUEST["year"];
    $prev_year = $cYear;
    $next_year = $cYear;
    $prev_month = $cMonth-1;
    $next_month = $cMonth+1;
    if ($prev_month == 0 ) {
    $prev_month = 12;
    $prev_year = $cYear - 1;
    }
    if ($next_month == 13 ) {
    $next_month = 1;
    $next_year = $cYear + 1;
    }
    ?>
    <table width="200">
    <tr align="center">
    <td bgcolor="#999999" style="color:#FFFFFF">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
    <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a> </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td align="center">
    <table width="100%" border="0" cellpadding="2" cellspacing="2">
    <tr align="center">
    <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
    </tr>
    <tr>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
    </tr>
    <?php
    $timestamp = mktime(0,0,0,$cMonth,1,$cYear);
    $maxday = date("t",$timestamp);
    $thismonth = getdate ($timestamp);
    $startday = $thismonth['wday'];
    for ($i=0; $i<($maxday+$startday); $i++)
	{
    	if(($i % 7) == 0 ) 
		{
			echo "<tr>n";
    	}
		if($i < $startday)
		{
			echo "<td></td>n";
    	}else
		{
			echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>n";
    	}if(($i % 7) == 6 ) echo "</tr>n";
    }
    ?>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>

Mohon petunjuk...
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Dec 29, 2012 · 0 Suka · 0 Tidak Suka
itu karena kamu lupa menambahkan backslash di depan hurup n (\n untuk karakter enter/new line). kamu bisa tambahkan \ atau dihapus saja.
<?php
include "../incl_db.php";
?>    
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Agenda</title>
    </head>  
    <body>
    <?php
    $monthNames = Array("January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December");
    ?>
    <?php
    if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
    if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
    ?>
    <?php
    $cMonth = $_REQUEST["month"];
    $cYear = $_REQUEST["year"];
    $prev_year = $cYear;
    $next_year = $cYear;
    $prev_month = $cMonth-1;
    $next_month = $cMonth+1;
    if ($prev_month == 0 ) {
    $prev_month = 12;
    $prev_year = $cYear - 1;
    }
    if ($next_month == 13 ) {
    $next_month = 1;
    $next_year = $cYear + 1;
    }
    ?>
    <table width="200">
    <tr align="center">
    <td bgcolor="#999999" style="color:#FFFFFF">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
    <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a> </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td align="center">
    <table width="100%" border="0" cellpadding="2" cellspacing="2">
    <tr align="center">
    <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
    </tr>
    <tr>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td>
    <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
    </tr>
    <?php
    $timestamp = mktime(0,0,0,$cMonth,1,$cYear);
    $maxday = date("t",$timestamp);
    $thismonth = getdate ($timestamp);
    $startday = $thismonth['wday'];
    for ($i=0; $i<($maxday+$startday); $i++)
	{
    	if(($i % 7) == 0 ) 
		{
			echo "<tr>\n";
    	}
		if($i < $startday)
		{
			echo "<td></td>\n";
    	}else
		{
			echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n";
    	}if(($i % 7) == 6 ) echo "</tr>\n";
    }
    ?>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>
0
Loading...
Ikram Shabri · Dec 31, 2012 · 0 Suka · 0 Tidak Suka
Maaf mas nanya lagi,

Kl saya mau pas dia klik tgl tertentu, muncul popup gmn y ? Jadi di popup itu dia masukin agendanya.
Saya bingung pas rumus javascript untuk nentuin parameter get elemen tanggal buat jd indikator dia popup...

Mohon petunjuk..