punithapary 0 Light Poster

Hi,
I am trying to do calendar with events.The events will take from databse my code is working but its taking only one value.i am using code like this
[
[<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,"<?PHP echo $events[ 0 ];?> " ]];

so its showing one valu if i chaged that into
[
[<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,<?PHP echo $events[ 0 ];?> ,"<?PHP echo $events[ 0 ];?> " ],[<?PHP echo $events[ 1];?> ,<?PHP echo $events[1 ];?> ,<?PHP echo $events[ 1 ];?> ,<?PHP echo $events[ 1];?> ,"<?PHP echo $events[ 1 ];?> "]];

i dont want to specify these values .when ever i am adding events in database it automatically display in calender like this please can any one help me.
Thanks in advance
Punithapary

<?PHP $hostname="localhost";
$username="root";
$password="";
$database="edesdigner";
$sql=mysql_connect("$hostname","$username","$password")or die(mysql_error());
mysql_select_db("$database");
mysql_query($sql);
$sql2=mysql_query("select * from events");
$sql3=mysql_num_rows($sql2);
$events = array();
$month = array();
$date = array();
while($sql3<=13 && $sql4=mysql_fetch_array($sql2)){
array_push($events,$sql4);
array_push($month,$sql4);
array_push($date,$sql4);
echo $sql4['month'];
echo $sql4['date'];
echo $sql4['event'];
}
?>


<HEAD>
<style type="text/css">

body {
   background-color : #effeff;
   }
div.hol {
   color : red;
   cursor:hand;
   }
td.outer {
   cellpadding : 2em;
   border : solid effeff;
   }

table.inner {
   background-color : #efefdd;
   font-size : 10pt;
   }

</style>

<script type="text/javascript">
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var daycounts = [31,28,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 29 days
//2002 firstdays = [1,4,4,0,2,5,0,3,6,1,4,6];
//var firstdays =    [2,5,5,1,3,6,1,4,0,2,5,0];
//2004 firstdays = [3,6,7,3,5,1,3,6,2,4,0,2];
var firstdays = [4,7,7,3,5,1,3,6,2,4,7,2];


// This is where you put in the appointments. follow pattern [fromday,frommonth,today,tomonth,message]
var apps =
 [
[<?PHP echo $events[ 0 ]['date'];?> ,<?PHP echo $events[ 0 ]['month'];?> ,<?PHP echo $events[ 0 ]['date'];?> ,<?PHP echo $events[ 0 ]['month'];?> ,"<?PHP echo $events[ 0 ]['event'];?> " ]];

function CheckDate(month,dayno)
{
   var retval = new String(dayno);
   var m = month + 1;

   for(var app = 0; app < apps.length; app++)
   {
      if(m == apps[app][1] ) //first monthz
      {
         if(apps[app][3] - apps[app][1] > 0)
         {
            if(dayno >= apps[app][0])
            {
               retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";
            }
         }
         else
         {
            if(dayno >= apps[app][0] && dayno <= apps[app][2])
            {
               retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";
            }
         }
      }
      else if(m == apps[app][3]) // second month
      {
         if(dayno <= apps[app][2])
         {
            retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";
         }
      }
      else if( m > apps[app][1] && m < apps[app][3] )
      {
         retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";
      }
   }

   return retval;
}

function PrintMonth(month)
{
   var done = false;
   var day = 1;

   document.write("<table class='inner'><caption><b>" + months[month] + "</b></caption><thead>");
   document.write("<th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th></thead>");
   while(!done)
   {
      document.write("<tr>");
      PrintWeek(month,day, firstdays[month], daycounts[month]);
      document.write("</tr>");
      day = day + 7;
      if( day > daycounts[month] + firstdays[month])
      {
         done = true;
      }
   }
   document.write("</tbody></table><p>");
}


function PrintWeek(monthno,start,min,max)
{
   var d;
   var desc;
   for(var j = 0; j < 7; j++)
   {
      document.write("<td>");
      d = start + j;
      if(d >= min && d < max + min)
      {
         desc = CheckDate(monthno,d - min + 1);
         document.write(desc);
      }
      document.write("</td>");
   }
}
</script>
</HEAD>


<BODY>
<center><h1>2009 Calendar</h1></center>

Hold mouse over date to see message

<table width="492" height="337" align="center">
<tr>
<td width="130" class="outer">
<script type="text/javascript">
PrintMonth(0);
</script>
</td>
</table>
<!-- Script Size:  5.48 KB -->