Note that there are some explanatory texts on larger screens.

plurals
  1. POCalendar PHP script modification
    primarykey
    data
    text
    <p>I'm developing this project that has a <strong>calendar system</strong>. To develop more efficiently, I got the calendar code <a href="http://www.newmediacampaigns.com/page/create-a-jquery-calendar-with-ajax-php-and-a-remote-data-source" rel="nofollow">from this site</a>.</p> <p>The original code is good: I've done some modifications, but I've got stuck in one of the modifications I need for my project. As the calendar works with a <strong>database dialog</strong>, I want it to show some of the columns of the database table inside its particular dates. For example, if I have a soccer event recorded in 2012/10/28 (similar to the original database code, from the site I mentioned), I want its title to be displayed in its relative date. I tried real hard, but I'm not finding a solution. Please, Help!</p> <p>The code I'm using to display the calendar is this:</p> <pre><code>$db = new PDO('mysql:host=localhost;dbname=calendar','root',''); $stmt = $db-&gt;prepare('SELECT time FROM events'); $stmt-&gt;execute(); $rawTimeStamps = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC); $cleanDateArray = array(); foreach ($rawTimeStamps as $t) { $rawDate = $t['time']; $rawDate = getdate($rawDate); $cleanDate = mktime(0,0,0,$rawDate['mon'],$rawDate['mday'],$rawDate['year']); $cleanDataArray[] = $cleanDate; } /* draw table */ $calendar = '&lt;table cellpadding="0" cellspacing="0" class="calendar"&gt;'; /* table headings */ $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $calendar.= '&lt;tr class="calendar-row"&gt;&lt;td class="calendar-day-head"&gt;'.implode('&lt;/td&gt;&lt;td class="calendar-day-head"&gt;',$headings).'&lt;/td&gt;&lt;/tr&gt;'; /* days and weeks vars now ... */ $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); /* row for week one */ $calendar.= '&lt;tr class="calendar-row"&gt;'; /* print "blank" days until the first of the current week */ for($x = 0; $x &lt; $running_day; $x++): $calendar.= '&lt;td class="calendar-day-np"&gt; &lt;/td&gt;'; $days_in_this_week++; endfor; /* keep going with days.... */ for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++): $calendar.= '&lt;td class="calendar-day"&gt;'; /* * Assign a unique id to the day number. This unique id will be * used by jQuery to locate events from the database that are * on this day. The unique id is the timestamp for the first minute * of $list_day of $month of $year. * * @author Josh Lockhart, http://www.newmediacampaigns.com, lines 40-41 */ $timestamp = mktime(0,0,0,$month,$list_day,$year); if (in_array($timestamp, $cleanDataArray)) { $calendar.= '&lt;div class="day-number day-number-event"&gt;&lt;a id="'.$timestamp.'" href="#"&gt;'.$list_day.'&lt;/a&gt;&lt;/div&gt;'; } else { $calendar.= '&lt;div class="day-number day-number-noevent"&gt;'.$list_day.'&lt;/div&gt;&lt;/div&gt;&lt;div id="calendar-events"&gt;&lt;/div&gt;'; } $calendar.= '&lt;/td&gt;'; if($running_day == 6): $calendar.= '&lt;/tr&gt;'; if(($day_counter+1) != $days_in_month): $calendar.= '&lt;tr class="calendar-row"&gt;'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; /* finish the rest of the days in the week */ if($days_in_this_week &lt; 8): for($x = 1; $x &lt;= (8 - $days_in_this_week); $x++): $calendar.= '&lt;td class="calendar-day-np"&gt; &lt;/td&gt;'; endfor; endif; /* final row */ $calendar.= '&lt;/tr&gt;'; /* end the table */ $calendar.= '&lt;/table&gt;'; /* all done, return result */ return $calendar; } </code></pre> <p>I've been triyng on every way my knowledge allows, but yet I'm kind of limited in PHP and MySQL. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload