Skip to content

Instantly share code, notes, and snippets.

var d = new Date();
var day = d.getDate(),
month = d.getMonth() + 1,
year = d.getFullYear(),
days_number = daysInMonth(month, year),
actual_d = d.getDate(),
actual_m = d.getMonth() + 1,
actual_y = d.getFullYear();
function firstDay(month, year) {
return new Date(year, (month - 1), 1).getDay(); // Sunday is 0, Monday is 1...
$(function() {
tbody = $("tbody");
$.ajax({
dataType: "json",
type: "POST",
data: { action: "select" },
url: "./php/events_table.php",
beforeSend: function() { tbody.html("<td colspan=\"4\" style=\"text-align: center; padding: 50px 0px;\">Loading events...</td>"); },
success: function(data) {
getEventsTable(data);
$(function() {
tbody = $("tbody");
$.ajax({
dataType: "json",
type: "POST",
data: { action: "select" },
url: "./php/events_table.php",
beforeSend: function() { tbody.html("<td colspan=\"4\" style=\"text-align: center; padding: 50px 0px;\">Loading events...</td>"); },
success: function(data) {
getEventsTable(data);
@facumartig
facumartig / date2.php
Last active December 20, 2015 02:18 — forked from ricardosiri68/date2.php
<?php
require_once 'config/db_config.php';
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%c-%e') selector FROM events WHERE DATE_FORMAT(timestamp, '%Y-%c') = '".$_POST['d']."' ORDER BY timestamp, id ASC";
$query = mysqli_query($link, $sql);
if (mysqli_num_rows($query) > 0){
$data = array();
while ($recset = mysqli_fetch_array($query)){
if(!array_key_exists($recset["selector"], $data)){
<?php
require_once 'config/db_config.php';
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%c-%e') selector FROM events WHERE DATE_FORMAT(timestamp, '%Y-%c') = '".$_POST['d']."' ORDER BY DATE_FORMAT(timestamp, '%Y%c%e'), id DESC";
$query = mysqli_query($link, $sql);
if (mysqli_num_rows($query) > 0){
$data = array(); $index = 0;
while ($recset = mysqli_fetch_array($query)){
$data[$index] = $recset;
CREATE TABLE `calendario`.`events` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`title` varchar(45) NOT NULL DEFAULT '',
`desc` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
<?php
require_once 'config/db_config.php';
$sql = "SELECT * FROM events WHERE timestamp = '".$_POST['d']."' ORDER BY ID";
$query = mysqli_query($link, $sql);
if (mysqli_num_rows($query) > 0){
$data = array(); $index = 0;
while ($recset = mysqli_fetch_array($query)){
$data[$index] = $recset;
@facumartig
facumartig / script.js
Last active December 20, 2015 00:39
JS
for (i = 1; i <= days_number; i++) {
if (month == actual_m && diap == actual_d) {
tbody.append("<td id=\"2013-07-16 00:00:00\" class=\"actual\"><span><a href=\"#myModal\" role=\"button\" class=\"days\" data-toggle=\"modal\">" + diap + "</a></span></td>");
}
else {
tbody.append("<td id=\"2013-07-16 00:00:00\"><span><a href=\"#myModal\" role=\"button\" class=\"days\" data-toggle=\"modal\">" + diap + "</a></span></td>");
}
if (i % 7 === 0) tbody.append("</tr><tr>");
<?php include './functions.php'; ?>
<tr>
<?php
for ($i = 1; $i <= 7; $i++){
if ($i < $primer_dia){
echo "<td><span></span></td>";
}
else {
echo "<td>".$diap."</td>";
$diap++;