Jump to content

need help with calendar


rockindano30

Recommended Posts

im working on a calendar. i have the calendar done but stuck on making it a active event calendar. i want the days that have events to be links. i have it customized with css but missing the links and events here is the code:

 

<?php 
        // Get values from query string
        $day = $_GET["day"];
        $month = $_GET["month"];
        $year = $_GET["year"];
        $sel = $_GET["sel"];
        $what = $_GET["what"]; 
        
        
        if($day == "")
        $day = date("j");
        
        if($month == "")
        $month = date("m");
        
        if($year == "")
        $year = date("Y"); 
        
        $currentTimeStamp = strtotime("$year-$month-$day");
        $monthName = date("F", $currentTimeStamp);
        $numDays = date("t", $currentTimeStamp);
        $counter = 0;
        $numEventsThisMonth = 0;
        $hasEvent = false;
        $todaysEvents = ""; 
        ?>
        <table width="100%" border='0' cellspacing='0' cellpadding='0'>
          <tr align="center">
            <td colspan='1' align="center"><input type='button' value='<<' onClick='goLastMonth(<?php echo $month . ", " . $year; ?>)'> 
            </td>
            <td colspan='5' align="center"><span class='title'><?php echo $monthName . " " . $year; ?></span><br>
            </td>
            <td width='20' colspan='1' align='right'><input type='button' value='>>' onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)'>
             </td>
          </tr>
          <tr>
            <td class='style2'>S</td>
            <td width='18' class='style2'>M</td>
            <td width='35' class='style2'>T</td>
            <td width='37' class='style2'>W</td>
            <td width='35' class='style2'>T</td>
            <td width='67' class='style2'>F</td>
            <td class='style2'>S</td>
          </tr>
          <?php
        $numDays = date("t", $currentTimeStamp); 
        for($i = 1; $i < $numDays+1; $i++, $counter++)
        {
        $timeStamp = strtotime("$year-$month-$i");
        if($i == 1)
        {
        // Workout when the first day of the month is
        $firstDay = date("w", $timeStamp);
        
        for($j = 0; $j < $firstDay; $j++, $counter++)
        echo "<td align='center'> </td>"; 
        
        } //end if 
        if(!($db = @ mysql_connect('localhost', 'username', 'password')))
                        {
                            echo 'Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.';
                            exit;
                        }
                        //select which database you want to edit
                        mysql_select_db("db name");
                        $event_id = $_GET["event_id"]; 
                        
                        
                        if(!isset($event_id))
                                {
                                    $query = "SELECT * FROM calendar";
                                    $result = mysql_query($query);

                                    while($r=mysql_fetch_array($result))
                                    {	
                                   //the format is $variable = $r["nameofmysqlcolumn"];
                                   //modify these to match your mysql table columns
                                   $event_id=$r["event_id"];
                                    $date=$r["dateevent"];
                                    
        //							for ($k=0; $k<count($date); $k++)
        //							if($i==$date)
        //							
        //							print $i;
                                   }
           //prints out all days here...................                     
        if($counter % 7 == 0)
        echo "</tr><tr align='center'>"; 
        
        if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
        echo "<td width='50' class='weekend' align='center'>$i</td>";
        else
        
        if($i == date("d") && $month == date("m") && $year == date("Y"))
        echo "<td width='50' class='today' align='center'>$i</td>";
        /*else
        if($i==$date)
        echo "<td width='50' class='normal' align='center' style=\"background-color:black\"><a href=''>$i</a></td>";
        */
        else
        echo "<td width='50' class='normal' align='center'>$i</td>";  
                            }//end if///////////////////////////
        }//end of for loop
        ?>
        
        
        </table>

 

 

HELP!!!!!!!

PLEASE!!!!!!!!!!!!!

ANYONE!!!!!!!!!!!!!!

Link to comment
https://forums.phpfreaks.com/topic/101740-need-help-with-calendar/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.