adzie Posted September 13, 2008 Share Posted September 13, 2008 Hello, I've found and modified a calendar script, I wish to recall entries from the database that are due on a particular day, I can get it to recall from the database entires but it doesnt define which month. How can I modify the date boxes to display an entry based on day and month and year from the database? many thanks <?php // Get values from query string $day = $_GET["day"]; $month = $_GET["month"]; $year = $_GET["year"]; $sel = $_GET["sel"]; $what = $_GET["what"]; $field = $_GET["field"]; $form = $_GET["form"]; 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 = "";*/ ?> <html> <head> <title>Calendar</title> <link rel="stylesheet" type="text/css" href="calendar.css"> <script language="javascript"> function goLastMonth(month,year,form,field) { // If the month is January, decrement the year. if(month == 1) { --year; month = 13; } document.location.href = 'index.php?month='+(month-1)+'&year='+year; } function goNextMonth(month,year,form,field) { // If the month is December, increment the year. if(month == 12) { ++year; month = 0; } document.location.href = 'index.php?month='+(month+1)+'&year='+year; } function sendToForm(val,field,form) { // Send back the date value to the form caller. eval("opener.document." + form + "." + field + ".value='" + val + "'"); window.close(); } </script> </head> <body style="margin:0px 0px 0px 0px" class="body"> <p> </p> <table width='700' border='1' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'> <tr> <td width='25' colspan='1'> <input type='button' class='button' value=' << ' onClick='<?php echo "goLastMonth($month,$year,\"$form\",\"$field\")"; ?>'> </td> <td width='125' align="center" colspan='5'> <span class='title'><?php echo $monthName . " " . $year; ?></span><br> </td> <td width='25' colspan='1' align='right'> <input type='button' class='button' value=' >> ' onClick='<?php echo "goNextMonth($month,$year,\"$form\",\"$field\")"; ?>'> </td> </tr> <tr> <td class='head' align="center" width='120'>M</td> <td class='head' align="center" width='120'>T</td> <td class='head' align="center" width='120'>W</td> <td class='head' align="center" width='120'>T</td> <td class='head' align="center" width='120'>F</td> <td class='head' align="center" width='120'>S</td> <td class='head' align="center" width='120'>S</td> </tr> <tr height='100' valign='top'> <?php /* Constants */ @define ("MYSQL_CONNECT_INCLUDE", "connect_db.php"); // MySQL database connection (a sample file is included) include(MYSQL_CONNECT_INCLUDE); 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 = 1; $j < $firstDay; $j++, $counter++) echo "<td width='120' class='entry'></td>"; } if($counter % 7 == 0) echo "</tr><tr height='120' valign='top'>"; $weekday = date("D", $timeStamp); $thst = date("S", $timeStamp); $digityear = date("Y", $timeStamp); $nummonth = date("m", $timeStamp); $numdays = date("d", $timeStamp); $weekno = date("W", $timeStamp); $query = "SELECT * FROM calendar WHERE `day`=$i"; $result = mysql_query($query); $numberofresults = mysql_numrows($result); $isthereanentry = mysql_fetch_row($result); echo "<td bgcolor='#ffffff' width='25' class='entry'> $weekday$i$thst$digityear $digityear$nummonth$numdays Week$weekno $numberofresults $isthereanentry </td>"; } ?> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/124082-calendar-event-retrieval/ Share on other sites More sharing options...
adzie Posted September 16, 2008 Author Share Posted September 16, 2008 any thoughts guys Link to comment https://forums.phpfreaks.com/topic/124082-calendar-event-retrieval/#findComment-643135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.