son Posted July 1, 2009 Share Posted July 1, 2009 I have a calendar script with a small calendar to select the day which then shows the relevant entries for the selected day in one-day-calendar format (so I display two calendars in total, one for month selection and one for display of entered activities). I would like to show the days in small calendar with red background where date matches one or more entries of my activies table (date stored in timestamp format), but am not sure how to compare relevant day in calendar with timestamp entry in table that holds activities. The code is so far (in bold my bad first attempts for the comparison):// accept incoming URL parameter$timestamp = (isset($_GET['t'])) ? $_GET['t'] : time();// determine useful aspects of the requested monthlist($month, $day, $year) = explode('/', date('m/d/Y', $timestamp));$first_day_of_month = date('w', mktime(0, 0, 0, $month, 1, $year));$total_days = date('t', $timestamp);// output table headerob_start();echo '<table id="calendar">';echo '<tr id="calendar_header"><th colspan="7">';echo '<a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . strtotime('-1 month', $timestamp) . '"><</a> ';echo date('F', $timestamp) . ' ' . $year;echo ' <a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . strtotime('+1 month', $timestamp) . '">></a>';echo '</th></tr>';echo '<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th>' . '<th>Fri</th><th>Sat</th></tr>';// output date cells$current = 1;while ($current <= $total_days){ echo '<tr class="calendar_dates">'; for ($i = 0; $i < 7; $i++) { if (($current == 1 && $i < $first_day_of_month) || ($current > $total_days)) { echo '<td class="empty"> </td>'; continue; }$qd = 'SELECT EVENT_NAME, UNIX_TIMESTAMP(EVENT_TSTAMP) AS EVENT_TSTAMP FROM %scalendar WHERE EVENT_TSTAMP = $current',$rd = mysql_query($qd, $GLOBALS['DB']); echo '<td'; if ($current == EVENT_TSTAMP) echo ' style="background-color:red"; echo '>'; echo $current; echo '</td>'; $current++; } echo '</tr>';}echo '</table>';$GLOBALS['TEMPLATE']['content'] = ob_get_clean();How do I obtain the day of timestamp?Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.