php calandar script with events need help please
<p>i'm currently working creating a calendar script that allows you to add events to the database and they appear as tool-tips</p>

<p>i want it too connect to the database if it isn't already connected and as the numbers are increasing and its creating the calandar if the day is equal to the $day in the event calandar it prints out a out the event and day with added class heres what i have right now but its not working right. </p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html&gt;

 &lt;head&gt;

  &lt;title&gt;Calandar&lt;/title&gt;

  &lt;link rel="stylesheet" href="css/master.css" type="text/css" media="screen" charset="utf-8" /&gt;

  &lt;script src="js/jquery-1.3.min.js" type="text/javascript"&gt; &lt;/script&gt;

  &lt;script src="js/coda.js" type="text/javascript"&gt; &lt;/script&gt;

 &lt;/head&gt;

 &lt;body&gt;

  &lt;table cellspacing="0"&gt;

   &lt;thead&gt;

    &lt;tr&gt;

    &lt;?php

     include 'connect.php';



     $days = mysql_query("Select * FROM calandar ORDER BY id");



     while($dayz = mysql_fetch_array($days)){

      if(is_array($dayz)){

       foreach($dayz as $key =&gt; $value)

        $$key = stripslashes($value);

      }

     echo "&lt;th&gt;".$day."&lt;/th&gt;";

     }

    ?&gt;

    &lt;/tr&gt;

   &lt;/thead&gt;

   &lt;tbody&gt;

    &lt;?php

     $date = time();

     $dayt = date('j', $date);

     $month = date('m', $date);

     $year = date('Y', $date);

     $first_day = mktime(0,0,0,$month, 1, $year);

     $month_title = date('F', $first_day);

     $days_of_week = date('D', $first_day);

     switch($days_of_week){

      case "Mon": $blank = 0; break;

      case "Tue": $blank = 1; break;

      case "Wed": $blank = 2; break;

      case "Thu": $blank = 3; break;

      case "Fri": $blank = 4; break;

      case "Sat": $blank = 5; break;

      case "Sun": $blank = 6; break;

     }

     $days_in_month = cal_days_in_month(0, $month, $year);


     //counts days goes up to 7

     $day_count = 1;

     echo "&lt;tr&gt;";

     //take care of blank days

     while($blank &gt; 0)

     {

      echo "&lt;td&gt;&lt;/td&gt;";

      $blank = $blank-1;

      $day_count++;

     }

     $day_num = 1;

     //count days until its equal to the days in the current month
    $days = mysql_query("Select * FROM events ORDER BY id");
    while($dayz = mysql_fetch_array($days)){
     if(is_array($dayz)){

        foreach($dayz as $key =&gt; $value)

         $$key = stripslashes($value);
        }
     while($day_num &lt;= $days_in_month)
     {
       if($day === $day_num){

        echo $day_num. ",";
        echo "&lt;td class='date_has_event'&gt; $day_num

          &lt;div class='events'&gt;

           &lt;ul&gt;

            &lt;li&gt;

             &lt;span class='title'&gt; $title &lt;/span&gt;

             &lt;span class='desc'&gt; $desc &lt;/span&gt;

            &lt;/li&gt;

           &lt;/ul&gt;

          &lt;/div&gt;

         &lt;/td&gt;";

       }else{
         echo $day_num;
         echo "&lt;td&gt; $day_num &lt;/td&gt;";

       }
       $day_num++;
       $day_count++;


      //echo "&lt;td&gt; $day_num &lt;/td&gt;";

      //$day_num++;

      //$day_count++;



      //if statement to check if its been a full week

      if($day_count &gt; 7)

      {

       echo "&lt;/tr&gt;&lt;tr&gt;";

       $day_count = 1;

      }

}
      }
     while($day_count &gt; 1 &amp;&amp; $day_count &lt;= 7)

     {

      echo"&lt;td&gt;&lt;/td&gt;";

      $day_count++;

     }

     echo "&lt;/tr&gt;";

?&gt;

   &lt;/tbody&gt;

   &lt;tfoot&gt;

    &lt;th&gt;Mon&lt;/th&gt;&lt;th&gt;Tue&lt;/th&gt;&lt;th&gt;Wed&lt;/th&gt;

    &lt;th&gt;Thu&lt;/th&gt;&lt;th&gt;Fri&lt;/th&gt;&lt;th&gt;Sat&lt;/th&gt;

    &lt;th&gt;Sun&lt;/th&gt;

   &lt;/tfoot&gt;

  &lt;/table&gt;

  &lt;input type="hidden" name="today" id="today" value="&lt;?php echo $dayt ?&gt;"&gt;

  &lt;script type="text/javascript"&gt;

   $(function () {

    var day = $("#today").val();

    $("td").each(function(i){

     //alert(i);

     if(i - 1 == day){

      $(this).addClass("today");

     }

    });

   });



  &lt;/script&gt;

 &lt;/body&gt;

&lt;/html&gt;
</code></pre>
