Tanya popup window pada kalender

Ikram Shabri · Jan 7, 2013
Misi gan...

Mau tanya ane udh bikin kalender agenda yang membaca data dari database. Nah untuk masukkan data ke database, ane mau bikin pake popup window. Tp blm jadi, udh ane taruh setelah
for ($i=0; $i<($maxday+$startday); $i++) tetep blm mau.
Ini script kalendernya...
<?php
include "file_koneksi.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>  
	<script type=text/javascript>
<!-- 

function launchevent(url){
	self.name = "opener"; 
	remote = open(url, "", "resizable,scrollbars,width=400,height=600,left=300,top=100");
} 
// -->
</script>
<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>
	</table>
	<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 "";
    }
	if($i < $startday) 
	{
		echo "<td></td>\n";
		//echo "<a href=2.php>".$i."</a>";
    }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 ($i - $startday + 1);
		
		echo "</td>\n";
	}
	if(($i % 7) == 6 )
	{
		echo "</tr>\n";
	}
}
?>

Mohon petunjuk..
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Jan 7, 2013 · 0 Suka · 0 Tidak Suka
<?php
include "file_koneksi.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>  
	<script type=text/javascript>
<!-- 
 
function launchevent(url){
	window.open(url, "mywindow", "resizable=1,scrollbars=1,width=400,height=600,left=300,top=100");
} 
// -->
</script>
<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>
	</table>
	<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 "";
    }
	if($i < $startday) 
	{
		echo "<td></td>\n";
		//echo "<a href=2.php>".$i."</a>";
    }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'" : '').">";
		$url = 'page.php?tgl='.($i - $startday + 1) // sesuaikan lagi dengan kodemu
		echo '<a href="javascript:launchevent(\'.$url.'\')">';
		echo ($i - $startday + 1);
		echo '</a>';
		echo "</td>\n";
	}
	if(($i % 7) == 6 )
	{
		echo "</tr>\n";
	}
}
?>
0
Loading...
Ikram Shabri · Jan 8, 2013 · 0 Suka · 0 Tidak Suka
Thanks bli,

Ane jg udh dapet model lain, abis utak-atik lg kmrn..
<?php
include "file_koneksi.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>
	</table>
	<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++) 
{
	
	//echo "<a href=2.php>".$i."</a><br>";
	if(($i % 7) == 0 ) 
	{
		echo "";
    }
	if($i < $startday) 
	{
		echo "<td></td>\n";
		//echo "<a href=2.php>".$i."</a>";
    }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)." 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";
	}
}
?>

Tp knp pas input dari 2 komputer yang berbeda ga mau sinkron y ? Jd misalnya di komp 2 masukkan data, di komp 1 dia harus refresh halaman dulu baru update.

Ada cara lain tdk bli buat dia otomatis update ?

Terima kasih...
0
Loading...
Ellyx Christian · Jan 9, 2013 · 0 Suka · 0 Tidak Suka
Quote:
Tp knp pas input dari 2 komputer yang berbeda ga mau sinkron y ? Jd misalnya di komp 2 masukkan data, di komp 1 dia harus refresh halaman dulu baru update.

Ada cara lain tdk bli buat dia otomatis update ?

Memang seperti itulah cara kerja website, antar komputer client tidak ada koneksi. Salah satu caranya adalah polling menggunakan ajax, jadi setiap beberapa detik gunakan ajak untuk mengecek apakah ada perubahan data, seperti pada ajax chat
0
Loading...
Ikram Shabri · Jan 9, 2013 · 0 Suka · 0 Tidak Suka
Ane jg nyari yang refresh otomatis pake ajax tp blm dap2. Kmrn pke meta http refresh, bisa update dan milih bulan (next dan previous) tapi setelah refresh balik lagi ke bulan awal.

Ada referensi ngga bli ?

Thanks
0
Loading...
Ellyx Christian · Jan 10, 2013 · 0 Suka · 0 Tidak Suka
0
Loading...
Ikram Shabri · Jan 11, 2013 · 0 Suka · 0 Tidak Suka
maaf bli, itu yang bagian databasenya diisi apa y ? ane udh nyoba malah jd ngga berwarna bli..
0
Loading...
Ellyx Christian · Jan 11, 2013 · 0 Suka · 0 Tidak Suka
bisa lihat kode yang sudah kamu buat?
0
Loading...
Ikram Shabri · Jan 14, 2013 · 0 Suka · 0 Tidak Suka
Sebenarnya ane bingung ngisi yang bagian userCount.php-nya sih bli...
Ini untuk calendar.php
<?php
include "file_koneksi.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>  
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script type="text/javascript">
    $(document).ready(function() {
    $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never 
    setInterval(function() {
    $('#result').load('user.php');
    }, 3000); // the "3000" here refers to the time to refresh the div. it is in milliseconds.
    });
</script>


    <body>
	
<?php
$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;
    }
    ?>
    <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>
	</table>
	<tr>
<td align="center">
<table width="100%" border="1" 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++) 
{
	
	//echo "<a href=2.php>".$i."</a><br>";
	if(($i % 7) == 0 ) 
	{
		echo "";
    }
	if($i < $startday) 
	{
		echo "<td></td>\n";

    }else 
	{
		
		echo "<td align='center' valign='middle' height='20px'".($jmlAcara > 0 ? " bgcolor='yellow'" : '').">";
		echo "<div id=\"result\"><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><div><br>";
		echo "</td>\n";
	}
	if(($i % 7) == 6 )
	{
		echo "</tr>\n";
	}
}
?>

Ini untuk user.php
<?php 
   include "file_koneksi.php";
    $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"];
	$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++) 
{
    $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 $sql;
}
?>