rockindano30 Posted April 18, 2008 Share Posted April 18, 2008 hello all, i'm currently working on a event calendar and i am stuck. i want it to display events on days that events are taking place. and those days to be links. here is cal 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> stuck on getting days to be active as links. help!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/101711-php-event-calendar-mod/ Share on other sites More sharing options...
rockindano30 Posted April 18, 2008 Author Share Posted April 18, 2008 hello all, i'm currently working on a event calendar and i am stuck. i want it to display events on days that events are taking place. and those days to be links. here is cal 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> stuck on getting days to be active as links. help!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/101711-php-event-calendar-mod/#findComment-520381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.