$enlace = mysqli_connect('localhost', 'samanthapino', 'RMTbZLkQQ6@*'); if (!$enlace) { die('No pudo conectarse: ' . mysqli_error()); } $bd_seleccionada = mysqli_select_db($enlace,'quinta_zertuche'); if (!$bd_seleccionada) { die ('No se puede usar calendar : ' . mysqli_error()); } if($_GET["m"]==""){ $_GET["m"]= date("m"); } if($_GET["y"]==""){ $_GET["y"]= date("Y"); } $mes = intval($_GET["m"]); $prox_mes = date("m", mktime(0,0,0,$_GET["m"]+1,1,$_GET["y"])); $prox_anio = date("Y", mktime(0,0,0,$_GET["m"]+1,1,$_GET["y"])); $ant_mes = date("m", mktime(0,0,0,$_GET["m"]-1,1,$_GET["y"])); $ant_anio = date("Y", mktime(0,0,0,$_GET["m"]-1,1,$_GET["y"])); $query = "SELECT * FROM phpc_events e RIGHT JOIN phpc_occurrences o ON e.eid = o.eid WHERE (YEAR(o.start_date) = ".$_GET["y"]." AND MONTH(o.start_date) = ".$_GET["m"].") OR (YEAR(o.start_ts) = ".$_GET["y"]." AND MONTH(o.start_ts) = ".$_GET["m"].");"; $result = mysqli_query($enlace,$query); $num = mysqli_num_rows($result); $events[] = array(); while ($row = mysqli_fetch_array($result)) { // echo $row["start_date"]; //array_push($events,array($row["start_date"] => array( 'text' => $row["catid"] ))); if($row["start_date"]!="") { $fecha = $row["start_date"];} if($row["start_ts"]!="") { $fecha = substr($row["start_ts"],0,10);} $events += array($fecha => $row["catid"]); } //print_r($events); /** * Returns the calendar's html for the given year and month. * * @param $year (Integer) The year, e.g. 2015. * @param $month (Integer) The month, e.g. 7. * @param $events (Array) An array of events where the key is the day's date * in the format "Y-m-d", the value is an array with 'text' and 'link'. * @return (String) The calendar's html. */ function build_html_calendar($year, $month, $events = null) { // CSS classes $css_cal = 'calendar'; $css_cal_row = 'calendar-row'; $css_cal_day_head = 'calendar-day-head'; $css_cal_day = 'calendar-day'; $css_cal_day_number = 'day-number'; $css_cal_day_blank = 'calendar-day-np'; $css_cal_day_event = 'calendar-day-event'; $css_cal_event = 'calendar-event'; // Table headings $headings = array('L', 'M', 'X', 'J', 'V', 'S', 'D'); // Start: draw table $calendar = "
| " . implode(" | ", $headings) . " | " . "|
| "; } // Keep going with days... for ($day = 1; $day <= $days_in_month; $day++) { // Check if there is an event today $cur_date = date('Y-m-d', mktime(0, 0, 0, $month, $day, $year)); $draw_event = false; if (isset($events) && isset($events[$cur_date])) { $draw_event = true; } // Day cell $calendar .= $draw_event ? " | " : " | ";
// Add the day number
$calendar .= " " . $day . " ";
// Insert an event for this day
if ($draw_event) {
/*$calendar .=
"" .
"" .
$events[$cur_date]['text'] .
"" .
" ";*/
if($events[$cur_date]['text']=="2"){
$calendar .="O " ;
}
if($events[$cur_date]['text']=="3"){
$calendar .="R " ;
}
}
// Close day cell
$calendar .= " | ";
// New row
if ($running_day == 7) {
$calendar .= "
| "; } } // Final row $calendar .= " |
![]() |
||||||||||||||||||
Calendario |
|
|||||||||||||||||