I study ajax as you suggested and come up with this code, but it still wont work.
Please help me figure out why it wont work???
in main page i put this:
<script>
function showData(godina, mjesec, dan)
{
showdiv();
/*if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
} */
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("ispis").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","analiza.php",true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("god =" + godina + "mj =" mjesec + "d =" + dan);
}
</script>
and i call JS function by this:
$calendar.= '<td onclick= showData('.$year.','.$month.','.$list_day.'); class="calendar-day_used">'.$list_day.'</td>';
in analiza.php I put:
<?php
if (array_key_exists('god', $_POST) && array_key_exists('mj', $_POST)) {
//xmlhttp.send("god =" + godina + "mj =" mjesec + "d =" + dan);
$godina = $_POST['god'];
$godina = $_POST['mj'];
$dan = = $_POST['d'];
//$mjesec = ($_POST['bar']);
// do stuff with params
$calendar = '<table cellpadding="0" cellspacing="0" class="calendar">';
$sql="SELECT * FROM `record` WHERE (`Datum` = '" . $godina . "-" . $mjesec . "-" . $dan. "')";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$row = mysql_fetch_array($result, MYSQL_BOTH);
$polje = explode("-", $row["Datum"]);
$calendar = 'Ime i prezime: '.$row["ime"].'<br>'.
'Datum dolaska je: ' . $row["Datum"].'<br>'.
'Datum dolaska je: ' . $polje[0] . '-' . $polje[1] . '-' . $polje[2]+$row["3"].'<br>'.
'Broj noćenja je: ' . $row["4"].'<br>'.
$calendar = '<\table>';
echo $calendar;
} else {
echo 'Invalid parameters!';
}
?>