Jump to content

event calendar help


rockindano30

Recommended Posts

hello all

 

trying to finish my event calendar but stuck on asigning the events to linking days.

 

help???????????

 

 

here is my 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 width="87" 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="87" colspan='1' align='center'><input type='button' value='>>' onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)'>
             </td>
          </tr>
          <tr>
            <td class='style2'>S</td>
            <td width='80' class='style2'>M</td>
            <td width='80' class='style2'>T</td>
            <td width='80' class='style2'>W</td>
            <td width='80' class='style2'>T</td>
            <td width='80' 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("edinburg_site");
                        $event_id = $_GET["event_id"]; 
                        
                        
                        if(!isset($event_id))
                                {
                                    $query = "SELECT * FROM calendar order by dateevent asc LIMIT 20";
                                    $result = mysql_query($query);

                                    while($r=mysql_fetch_array($result))
                                    {	
                                   //the format is $variable = $r["nameofmysqlcolumn"];
                                    $event_id=$r["event_id"];
                                    $date=$r["dateevent"];
								$title=$r["title"];

								print $date."<br />";

                                   }
           //prints out all days here...................                     
        if($counter % 7 == 0)
        print "</tr><tr align='center'>"; 
        
        if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
	print "<td width='50' class='weekend' align='left'>$i</td>";
        else
        if($i == date("d") && $month == date("m") && $year == date("Y"))
        print "<td width='50' class='today' align='left'><div id=\"links\"><a href\"\">$i<span>$title</span></a></div></td>";
        else		
        print "<td width='50' class='normal' align='left'><div id=\"links\"><a href\"\">$i<span>$title</span></a></div></td>";  
	if(isset($date) && $date==$i)
	print "there is an event on today";
                            }//end if///////////////////////////
        }//end of for loop
        ?>
        </table>

Link to comment
https://forums.phpfreaks.com/topic/102927-event-calendar-help/
Share on other sites

ginger,

 

well its a calendar that should show a pop up floating box with the name of  the event and a link to cal.php page with will give more info to that event.

 

well it works. the calendar works and the floating box that suppose to show the title of the event works as well. i have the calendar db with events and floating box does show the first title of the first event that is in the array $date. so my problem is going through that array and displaying the event in the proper date in the calendar.

 

don't know if i am making sense or not.

 

Link to comment
https://forums.phpfreaks.com/topic/102927-event-calendar-help/#findComment-527250
Share on other sites

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.