Refresh Calendar

Ikram Shabri · Feb 13, 2013
Halo master2 sekalian..
mau nanya nih, ane kan bikin calendar agenda. Ketika ada 2 user berbeda (user A dan B) akses bulan yang sama, dan setelah user A/B input agenda, user lain dia mesti refresh manual kalendernya baru bisa liat agenda yang tadi dimasukkan.

Udh nyoba pake ajax, blm berhasil2 gan.
Ini script kalendernya..
<?php
session_start();
include "con.php";
if (isset($_SESSION['user']))
{

 $sql="";
	echo"<html>";
	echo"<head>";
	echo"<title>Agenda</title>";
	echo"</head>"; 
	echo"<body>";
	

	$monthNames = Array("January","February","March","April","May","June","July","August","September","October","November", "December");
    
    if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
    if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
	   
    $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;
    }
    
	echo"<table width=200>";
	echo"<tr align=center>";
	echo"<td bgcolor=#999999 style=color:#FFFFFF>";
	echo"<table width=100% border=0 cellspacing=0 cellpadding=0>";
	echo"<tr>";
	echo"<td width=50% align=left><a href=$_SERVER[PHP_SELF]?month=". $prev_month . "&year=" . $prev_year." 	style=color:#FFFFFF>Previous</a></td>";
	echo"<td width=50% align=right><a href=$_SERVER[PHP_SELF]?month=". $next_month . "&year=" . $next_year." style=color:#FFFFFF>Next</a></td>";
	echo"</tr>";
	echo"</table>";
	echo"</td>";
	echo"</tr>";
	echo"</table>";
	echo"<tr>";
	echo"<td align=center>";
	echo"<table width=100% border=1 cellpadding=2 cellspacing=2>";
	echo"<tr align=center>";
	echo"<td colspan=7 bgcolor=#999999 style=color:#FFFFFF><strong>".$monthNames[$cMonth-1]." ".$cYear."</strong></td>";
	echo"</tr>";
	echo"<tr>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>S</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>M</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>T</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>W</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>T</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>F</strong></td>";
	echo"<td align=center bgcolor=#999999 style=color:#FFFFFF><strong>S</strong></td>";
	echo"</tr>";
	
	$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++) 
	{
	
	//echo "<a href=2.php>".$i."</a><br>";
		if(($i % 7) == 0 ) 
		{
			echo "";
    	}
		if($i < $startday) 
		{
			echo "<td></td>\n";

    	}else 
		{
			$sql = "select * from data_agenda where tgl_agenda='".($i - $startday + 1).'-'.$cMonth.'-'.$cYear."'";
			$hs = mysql_query($sql);
			$jmlAcara = mysql_num_rows($hs);
			echo "<td align='center' valign='middle' height='20px'".($jmlAcara > 0 ? " bgcolor='yellow'" : '').">";
			echo "<a href=2.php?tgl=".urlencode($i - $startday + 1)."&month=".urlencode($monthNames[$cMonth-1])." onclick=\"window.open(this.href,'window','width=640,height=480,resizable,scrollbars,toolbar,menubar') ;return false;\">".($i - $startday + 1)."</a><br>";
			echo "</td>\n";
		}
		if(($i % 7) == 6 )
		{
			echo "</tr>\n";
		}
	}
	echo"</table>";
	echo"<br><br><center><a href=logout.php>Logout</a>";
	
}else
{
	echo "<script>alert('Please login first');javascript:window.location.href='index.php';</script>";
}
?>

Mohon bantuan dan petunjuknya..

Thanks before,
Silahkan login untuk menjawab!
0
Loading...
MyPHPtutorials · Feb 21, 2013 · 0 Suka · 0 Tidak Suka
analoginya seperti ini:
jika saya punya sebuah halaman random.php, seperti:
<?php
echo mt_rand();
?>
kemudian saya punya halaman index.php seperti:
<html>
	<head>
		<title>Test</title>
	</head>
	<body>
		<div id="random"></div>
	</body>
</html>
dan saya ingin menampilkan halaman random.php di dalam <div id="random"></div>, realtime setiap 1 detik. Maka saya akan tambahkan jquery/ajax pada halaman index.php seperti:
<html>
	<head>
		<title>Test</title>
		<!-- tambahkan jquery -->
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript">
			function loadRandom(){
				$('#random').load('random.php',{}, function(){
					setTimeout("loadRandom()",1000);
				});
			}
		</script>
	</head>
	<body>
		<div id="random"></div>
	</body>
</html>
0
Loading...
Ikram Shabri · Mar 20, 2013 · 0 Suka · 0 Tidak Suka
Udh ane coba, tp msh bingung ksh hyperlink di previous dan next buttonnya bli.
Cuma bisa 1 kali next dan previous, setelah itu tidak bisa...

Thanks,
0
Loading...
Ellyx Christian · Mar 20, 2013 · 0 Suka · 0 Tidak Suka
coba lihat kode yang sudah dibuat