fullcalendar json is not working - fullcalendar

I am having a hardtime trying to populate events on fullcalendar, following is my code, trying to fetch data from mysql
class mycalendarleaves extends Generic{
function calendar_LeaveDetails(){
$year = date('Y');
$month = date('m');
$this->user_id = $_SESSION['user_id'];
$params = array( ':user_id' => $this->user_id );
$stmt = parent::query("SELECT * FROM messages WHERE TYPE = 'leave' AND leave_status='approved' AND sender_id = :user_id;", $params);
while($value = $stmt->fetch()) :
$_SESSION['cal_data'] = array(
'id' => $value['id'],
'title' => $value['sender_name'],
'start' => "$year-$month-10"
);
endwhile;
}
}
echo json_encode($_SESSION['cal_data']);
$mycalendarleaves = new mycalendarleaves();
here is the script
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "calendar.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
I dont get any error, the calendar still appears blank without data. what am i doing wrong?

I got it to work, incase someone else is having a problem may be this will help them as well.
following is my function that is fetching data from mysql
function calendar_EventDetails(){
$year = date('Y');
$month = date('m');
$this->id = $_SESSION['id'];
$params = array( ':id' => $this->id );
$stmt = parent::query("SELECT * FROM TABLENAME WHERE TYPE = 'event' AND status='approved' AND id = :id;", $params);
unset($_SESSION['events']);
while($value = $stmt->fetch()) :
$_SESSION['events'][] = array(
'id' => $value['id'],
'title' => $value['name'],
'start' => "$year-$month-10"
);
endwhile;
}
Following is the script which is calling the php file where the above function is placed
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "calendar.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});

Related

Drupal 7: How to send HTML Email

Could someone tell me what i am missing to send an HTML email using Drupal's function? Here is my call:
try{
drupal_mail('my_module', 'forgot', $node->field_email_address['und'][0]['value'], language_default(), array('reset_key' => $key),'do-not-reply#myemailaddress.com');
}catch(Exception $e){
print_r($e->getMessage());die();
}
And here is the function:
function my_module_mail($key, &$message, $params) {
$body = '<p>Click the link below to reset your password.</p>
<p>Click this link to reset your password</p>
';
// $headers = array(
// 'MIME-Version' => '1.0',
// 'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
// 'Content-Transfer-Encoding' => '8Bit',
// 'X-Mailer' => 'Drupal'
// );
// $message['headers'] = $headers;
$message['subject'] = 'Why wont this send html??';
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8;';
$message['body'][] = $body;
$message['from'] = 'do-not-reply#myemailaddress.com';
}
I tired just the html header and the full set that is commented out. What am I missing? The email sends fine but it's plain text. Thanks and let me know!
You can use this function
function my_module_custom_drupal_mail($target = NULL, $from = null, $subject, $message, $attachment = NULL){
$my_module = 'my_module';
$my_mail_token = microtime();
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => $target,
'subject' => $subject,
'body' => array($message),
'module' => $my_module,
'key' => $my_mail_token,
'from' => "$from <email#email.com>",
'headers' => array(
'From' => "$from <email#email.com>",
'Sender' => "$from <email#email.com>",
'Return-Path' => "$from <email#email.com>",
'Content-Type' => 'text/html; charset=utf-8'
),
);
if ($attachment) {
$file_content = file_get_contents($attachment[0]);
$message['params']['attachments'][] = array(
'filecontent' => $file_content,
'filename' => $attachment[1],
'filemime' => $attachment[2],
);
}
$system = drupal_mail_system($my_module, $my_mail_token);
$message = $system->format($message);
if ($system->mail($message)) {
return TRUE;
}
else {
return FALSE;
}
}
AND call it like :
$body = '<p>Click the link below to reset your password.</p>
<p>Click this link to reset your password</p>
';
$subject ='Why wont this send html??';
$from = 'myemail#email.com';
$sent = my_module_custom_drupal_mail($node->field_email_address['und'][0]['value'], $from, $subject, $body);
Customize it like you want ! :)
A few things need to be done:
/**
* Class SomeCustomModuleMailSystem Implements MailSystemInterface.
*
* Used to enable HTML email to be sent.
*/
class SomeCustomModuleMailSystem extends DefaultMailSystem {
public function format(array $message) {
$message['body'] = implode("\n\n", $message['body']);
$message['body'] = drupal_wrap_mail($message['body']);
return $message;
}
}
This to be done one time, so probably in a hook_enable or hook_update:
$current = variable_get('mail_system', ['default-system' => 'DefaultMailSystem']);
$addition = ['some_custom_module' => 'SomeCustomModuleMailSystem'];
variable_set('mail_system', array_merge($current, $addition));
Invoke hook_mail as normal, e.g.
/**
* Implements hook_mail().
*/
function some_custom_module_mail($key, &$message, $params) {
switch ($key) {
case 'some_mail_key':
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8;';
$message['subject'] = $params['subject'];
$message['body'][] = $params['body'];
break;
}
}
Finally call it with something like this:
// Set variables required for the email.
$module = 'some_custom_module';
$key = 'some_mail_key';
$to = $email = 'thetoaddress#something.com';
$language = language_default();
$params['subject'] = 'Email subject';
$params['body'] = '<html><body>The HTML!</body></html>';
$from = 'thefromaddress#something.com';
$send = TRUE;
// Send the mail and log the result.
$result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
if ($result['result'] === TRUE) {
watchdog('some_custom_module', 'HTML email successfully sent.', [], WATCHDOG_INFO);
}
else {
watchdog('some_custom_module', 'HTML email failed to send', [], WATCHDOG_ERROR);
}

AJAX success response is not working but it's saving my changes

I'm a beginner in jQuery-Ajax so please bear with me. My Ajax response does not seem to load but my changes are being saved. but gives me this error on admin-ajax.php "call_user_func() expects parameter 1 to be a valid callback, function '_update_post_ter_count' not found or invalid function name".
Here is my function, could you point what i'm doing wrong?
add_action( 'wp_ajax_nopriv_save_sort', 'ccmanz_save_reorder' );
add_action('wp_ajax_save_sort','ccmanz_save_reorder');
function ccmanz_save_reorder() { //checking
//verify user intent
check_ajax_referer( 'wp-job-order', 'security' ); // this comes from wp_localize_script() in hrm-jobs.php
//capability check to ensure use caps
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have permission to access this page.' ) );
}
$order = explode( ',', $_POST['order'] );
$counter = 0;
foreach ( $order as $item_id ) {
$post = array(
'ID' => (int) $item_id,
'menu_order' => $counter,
);
wp_update_post( $post );
$counter ++;
}
wp_send_json_success('POST SAVED');
}
My Ajax Call
jQuery(document).ready(function($) {
sortList = $( 'ul#custom-type-list' ); //store
var animation = $ ( '#loading-animation' );
var pageTitle = $ ( 'div h2');
sortList.sortable({
update: function ( event, ui) {
animation.show();
$.ajax({
url: ajaxurl, // ajaxurl is defined by WordPress and points to /wp-admin/admin-ajax.php
type: 'POST',
async: true,
cache: false,
dataType: 'json',
data:{
action: 'save_sort', // Tell WordPress how to handle this ajax request
order: sortList.sortable( 'toArray' ).toString(), // Passes ID's of list items in 1,3,2 format
security: WP_JOB_LISTING.security
},
success: function( response ) {
animation.hide();
$('div.updated').remove();
if( true === response.success ) {
console.log(sortList.sortable( 'toArray' ));
pageTitle.after(
'<div id="messsage" class="updated"><p>' + WP_JOB_LISTING.success + '</p></div>'
);
} else {
$('div.error').remove();
pageTitle.after( '<div id="messsage" class="error"><p>' + WP_JOB_LISTING.failure + '</div>' );
}
},
error: function ( error ) {
$( 'div.error' ).remove();
animation.hide();
//pageTitle.after( '<div id="messsage" class="error"><p>' + WP_JOB_LISTING.failure + '</div>' );
}
});
}//update
}); //sortable
});//jquery

WooCommerce Variations as Radio Buttons

is it possible within WooCommerce to change the variations dropdown into radio buttons without having to work with a plugin? I would like to have the following setup on the variations section:
1 liter (10€)
2 liter (20€)
3 Liter (25€)
The price at the bottom should be automatically changed when you select an option.
Thank you
EDIT: added variation_check() and JS variation checking thanks to #ThomasB!
EDIT2: make sure variation_check() also checks for backorder status to allow selection when a product can be backordered.
The best way I managed to get this working is to add radio button markup directly after the select dropdowns and then hide the select dropdowns using CSS. You'll also need some custom JS to trigger the hidden select value changes so that your price will change according to the radio button you select.
Here's how I added the markup:
function variation_radio_buttons($html, $args) {
$args = wp_parse_args(apply_filters('woocommerce_dropdown_variation_attribute_options_args', $args), array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
'show_option_none' => __('Choose an option', 'woocommerce'),
));
if(false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product) {
$selected_key = 'attribute_'.sanitize_title($args['attribute']);
$args['selected'] = isset($_REQUEST[$selected_key]) ? wc_clean(wp_unslash($_REQUEST[$selected_key])) : $args['product']->get_variation_default_attribute($args['attribute']);
}
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_'.sanitize_title($attribute);
$id = $args['id'] ? $args['id'] : sanitize_title($attribute);
$class = $args['class'];
$show_option_none = (bool)$args['show_option_none'];
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __('Choose an option', 'woocommerce');
if(empty($options) && !empty($product) && !empty($attribute)) {
$attributes = $product->get_variation_attributes();
$options = $attributes[$attribute];
}
$radios = '<div class="variation-radios">';
if(!empty($options)) {
if($product && taxonomy_exists($attribute)) {
$terms = wc_get_product_terms($product->get_id(), $attribute, array(
'fields' => 'all',
));
foreach($terms as $term) {
if(in_array($term->slug, $options, true)) {
$id = $name.'-'.$term->slug;
$radios .= '<input type="radio" id="'.esc_attr($id).'" name="'.esc_attr($name).'" value="'.esc_attr($term->slug).'" '.checked(sanitize_title($args['selected']), $term->slug, false).'><label for="'.esc_attr($id).'">'.esc_html(apply_filters('woocommerce_variation_option_name', $term->name)).'</label>';
}
}
} else {
foreach($options as $option) {
$id = $name.'-'.$option;
$checked = sanitize_title($args['selected']) === $args['selected'] ? checked($args['selected'], sanitize_title($option), false) : checked($args['selected'], $option, false);
$radios .= '<input type="radio" id="'.esc_attr($id).'" name="'.esc_attr($name).'" value="'.esc_attr($option).'" id="'.sanitize_title($option).'" '.$checked.'><label for="'.esc_attr($id).'">'.esc_html(apply_filters('woocommerce_variation_option_name', $option)).'</label>';
}
}
}
$radios .= '</div>';
return $html.$radios;
}
add_filter('woocommerce_dropdown_variation_attribute_options_html', 'variation_radio_buttons', 20, 2);
function variation_check($active, $variation) {
if(!$variation->is_in_stock() && !$variation->backorders_allowed()) {
return false;
}
return $active;
}
add_filter('woocommerce_variation_is_active', 'variation_check', 10, 2);
And here's the JS I used:
$(document).on('change', '.variation-radios input', function() {
$('.variation-radios input:checked').each(function(index, element) {
var $el = $(element);
var thisName = $el.attr('name');
var thisVal = $el.attr('value');
$('select[name="'+thisName+'"]').val(thisVal).trigger('change');
});
});
$(document).on('woocommerce_update_variation_values', function() {
$('.variation-radios input').each(function(index, element) {
var $el = $(element);
var thisName = $el.attr('name');
var thisVal = $el.attr('value');
$el.removeAttr('disabled');
if($('select[name="'+thisName+'"] option[value="'+thisVal+'"]').is(':disabled')) {
$el.prop('disabled', true);
}
});
});
I don't know how to do that without a plugin, but I suggest you drop that requirement, and use the Woocommerce Radio Buttons plugin. This does exactly what you want:
You can use Variation Swatches for WooCommerce plugin. It worked for me.
I extended further the JavaScript part of cfx' answer to include cases of multiple variations. The idea is to hide and show available variations (radio buttons) based on the select inputs.
<script>
jQuery(document).on('change', '.variation-radios input', function() {
jQuery('.variation-radios input:checked').each(function(index, element) {
let el = jQuery(element);
jQuery('select[name="' + el.attr('name') + '"]').val(el.attr('value')).trigger('change');
recreateRadioInputs();
});
});
jQuery(document).on('woocommerce_update_variation_values', function() {
jQuery('.variation-radios input').each(function(index, element) {
let el = jQuery(element);
el.removeAttr('disabled');
if(jQuery('select[name="' + el.attr('name') + '"] option[value="' + el.attr('value') + '"]').is(':disabled')) {
$el.prop('disabled', true);
}
});
});
// recreate readio inputs based on the select inputs
function recreateRadioInputs() {
jQuery('.variation-radios input, .variation-radios label').hide();
jQuery('.variations select').each(function() {
let inputName = jQuery(this).attr('name');
jQuery(this).find('option').each(function() {
let inputVal = jQuery(this).val();
let radioInput = jQuery('.variation-radios input[value="' + inputVal + '"]');
jQuery('.variation-radios label[for="' + radioInput.attr('id') + '"]').show();
radioInput.show();
});
});
}
</script>

Wordpress wp_footer not loading

I'm using a theme which i've used before and the wp_footer is loading fine in there. But in the new site the wp_footer is not loading can't find the solution by myself! Is there someone who could help me?
it's in the right place before the </body> tag.
<footer>
<div class="container">
<div class="footermenu">
<?php
$footer = array(
'theme_location' => '',
'menu' => 'footer',
'container' => 'div',
'container_class' => '',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth' => 0,
'walker' => ''
);
wp_nav_menu($footer);
?>
<img src="http://www.web-lynx.nl/vandervalk/wp-content/uploads/2014/07/PBRB_logo-trans-300x41.png" width="300px" height="41px" class="logofooter"/>
<div class="clear"></div>
</div>
<h2><?php _e("ONZE SOCIAL MEDIA","vertaling"); ?></h2>
<div class="one_third">
<span data-icon="" class="footersocial"></span>
</div>
<div class="one_third">
<span data-icon="" class="footersocial"></span>
</div>
<div class="one_third">
<span data-icon="" class="footersocial"></span>
</div>
<div class="clear"></div>
<br>
Copyright © Van der Valk
</div>
</footer><!-- footer -->
</div><!-- site-wrapper -->
<script type="text/javascript">
jQuery('.googlemaps').click(function(){
if(jQuery('.gmap').css('display') == 'none'){
jQuery('.gmap').slideDown();
}else{
jQuery('.gmap').slideUp();
}
});
jQuery('.firstphone').click(function(){
jQuery('.otherphonenumbers').slideDown();
});
</script>
<script>
/*!
* classie v1.0.0
* class helper functions
* from bonzo https://github.com/ded/bonzo
* MIT license
*
* classie.has( elem, 'my-class' ) -> true/false
* classie.add( elem, 'my-new-class' )
* classie.remove( elem, 'my-unwanted-class' )
* classie.toggle( elem, 'my-class' )
*/
/*jshint browser: true, strict: true, undef: true, unused: true */
/*global define: false */
( function( window ) {
'use strict';
// class helper functions from bonzo https://github.com/ded/bonzo
function classReg( className ) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
// classList support for class management
// altho to be fair, the api sucks because it won't accept multiple classes at once
var hasClass, addClass, removeClass;
if ( 'classList' in document.documentElement ) {
hasClass = function( elem, c ) {
return elem.classList.contains( c );
};
addClass = function( elem, c ) {
elem.classList.add( c );
};
removeClass = function( elem, c ) {
elem.classList.remove( c );
};
}
else {
hasClass = function( elem, c ) {
return classReg( c ).test( elem.className );
};
addClass = function( elem, c ) {
if ( !hasClass( elem, c ) ) {
elem.className = elem.className + ' ' + c;
}
};
removeClass = function( elem, c ) {
elem.className = elem.className.replace( classReg( c ), ' ' );
};
}
function toggleClass( elem, c ) {
var fn = hasClass( elem, c ) ? removeClass : addClass;
fn( elem, c );
}
var classie = {
// full names
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
toggleClass: toggleClass,
// short names
has: hasClass,
add: addClass,
remove: removeClass,
toggle: toggleClass
};
// transport
if ( typeof define === 'function' && define.amd ) {
// AMD
define( classie );
} else {
// browser global
window.classie = classie;
}
})( window );
(function( window ){
var body = document.body,
mask = document.createElement("div"),
togglePushLeft = document.querySelector( ".toggle-push-left" ),
pushMenuLeft = document.querySelector( ".push-menu-left" ),
activeNav
;
mask.className = "mask";
/* push menu left */
togglePushLeft.addEventListener( "click", function(){
classie.add( body, "pml-open" );
document.body.appendChild(mask);
activeNav = "pml-open";
} );
/* hide active menu if mask is clicked */
mask.addEventListener( "click", function(){
classie.remove( body, activeNav );
activeNav = "";
document.body.removeChild(mask);
} );
})( window );
</script>
<?php wp_footer(); ?>
</body>
</html>
Think it has something to do with this bug!
wp-content/themes/ParadiseHotel/st-framework/admin/page-builder/page-builder.php:50 - Undefined variable: ajax_nonce
this variable is set like this
<?php
#-------------------------------------------------------------
# Smooth Theme Framework Version
#-------------------------------------------------------------
function st_framework_version_init(){
$st_framework_version = '1.0';
if(get_option('st_framework_version_init') != $st_framework_version){
update_option('st_framework_version',$st_framework_version);
}
}
add_action('init','st_framework_version_init',10);
#-------------------------------------------------------------
# Define Admin Path and URL
#-------------------------------------------------------------
define('ST_ADMIN_PATH',dirname(__FILE__));
define('ST_ADMIN_URL',ST_URL.'admin');
define('ST_PAGE_TITLE',ST_THEME_NAME.' Settings Page'); // Theme Option Title
define('ST_MENU_TITLE',ST_THEME_NAME); // Theme Option Menu Title
define('ST_PAGE_SLUG','smooththemes'); // Theme Option URL Slug
#-------------------------------------------------------------
# Load the required Framework Files
#-------------------------------------------------------------
// kiểm tra tính hợp lệ của ajax
$current_user = wp_get_current_user();
$ajax_nonce = wp_create_nonce($current_user->ID);
//check_ajax_referer( $current_user->ID, 'ajax_nonce' );
if(is_admin()){
add_action( 'wp_ajax_smooththemes_save_option_action', 'smooththemes_save_option_action' );
function smooththemes_save_option_action() {
$st_default_lang_code = get_bloginfo('language'); // DO NOT REMOVE
if(isset($_POST['save']) && $_POST['save']=='Y'){
$data = array();
foreach( $_POST as $key => $arr ){
if(strpos($key, ST_SETTINGS_OPTION)!==false){
$k = str_replace(ST_SETTINGS_OPTION.'_', '', $key);
$data[$k]= $arr;
}
}
if(st_is_wpml()){
// ICL_LANGUAGE_CODE
// echo var_dump($st_default_lang_code,ICL_LANGUAGE_CODE);
if($st_default_lang_code==ICL_LANGUAGE_CODE || ICL_LANGUAGE_CODE=='' || strpos($st_default_lang_code,ICL_LANGUAGE_CODE)!==false){
// update_option(ST_FRAMEWORK_SETTINGS_OPTION,$_POST[ST_FRAMEWORK_SETTINGS_OPTION]);
update_option(ST_SETTINGS_OPTION,$data);
}
update_option(ST_SETTINGS_OPTION.'_'.ICL_LANGUAGE_CODE, $data);
do_action('st_save_options',$data);
}else{
echo ST_SETTINGS_OPTION;
update_option(ST_SETTINGS_OPTION,$data);
do_action('st_save_options', $data );
}
flush_rewrite_rules();
}
echo 1;
die();
}
// for media
function st_image_attachment_fields_to_edit($form_fields, $post){
$form_fields["st_custom"]["label"] = '';
$form_fields["st_custom"]["input"] = "html";
$image_attributes = wp_get_attachment_image_src( $post->ID ,'medium' ); // returns an array
$form_fields["st_custom"]["html"] = '
<input type="hidden" class="st_attach_btn" data-src = "'.$image_attributes[0].'" post_id ="'.$post->ID.'" >
';
return $form_fields;
}
add_filter("attachment_fields_to_edit", "st_image_attachment_fields_to_edit", null, 99);
//----------------Show image size in mediabox-------------------
function st_insert_custom_image_sizes( $sizes ) {
// get the custom image sizes
global $_wp_additional_image_sizes;
// if there are none, just return the built-in sizes
if ( empty( $_wp_additional_image_sizes ) )
return $sizes;
// add all the custom sizes to the built-in sizes
foreach ( $_wp_additional_image_sizes as $id => $data ) {
// take the size ID (e.g., 'my-name'), replace hyphens with spaces,
// and capitalise the first letter of each word
if ( !isset($sizes[$id]) )
$sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
}
return $sizes;
}
add_filter( 'image_size_names_choose', 'st_insert_custom_image_sizes' );
include(ST_ADMIN_PATH.'/editor/editor.php');
include(ST_ADMIN_PATH.'/admin-users.php');
include(ST_ADMIN_PATH.'/admin-functions.php');
include(ST_ADMIN_PATH.'/admin-menu.php');
include(ST_ADMIN_PATH.'/admin-scripts.php');
include(ST_ADMIN_PATH.'/ajax-media.php');
// include(ST_ADMIN_PATH.'/ajax-slidebar-generator.php');
//
if(file_exists(ST_ADMIN_PATH.'/page-builder/page-builder.php')){
include(ST_ADMIN_PATH.'/page-builder/page-builder.php');
}
if(file_exists(ST_ADMIN_PATH.'/review-control/review.php')){
include(ST_ADMIN_PATH.'/review-control/review.php');
}
include(ST_ADMIN_PATH.'/admin-meta-box.php');
include(ST_DIR.'/settings/meta-box-settings.php');
include(ST_ADMIN_PATH.'/admin-post-type.php');
include(ST_ADMIN_DIR.'admin-customize.php');
include(ST_ADMIN_DIR.'post-type-meta/event.php');
include(ST_ADMIN_DIR.'post-type-meta/room.php');
include(ST_ADMIN_DIR.'post-type-meta/gallery.php');
}

Full Calendar not displaying my events from my database

The events from my database are not displayed on my Full Calendar. I used the codes from the examples that I've seen online so please bear with the codes that I have right now. I would appreciate all the help that I will get from you guys. Thanks!
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},editable: false,
events: "json_events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
</script>
json_events.php
<?php
include 'connect.php';
session_start();
$result = mysql_query("SELECT ID, title, startDate AS startDate FROM events");
mysql_close();
$events = array();
while ($row=mysql_fetch_array($result)){
$title = $row['title'];
$eventsArray['id'] = $row['ID'];
$eventsArray['title'] = $title;
$eventsArray['startDate'] = $row['startDate'];
$events[] = $eventsArray;
}
echo json_encode($events);
?>
<?php
include 'connect.php';
session_start();
$result = mysql_query("SELECT ID, title, startDate AS startDate FROM events");
mysql_close();
$events = array();
while ($row=mysql_fetch_array($result)){
$id = $row['ID'];
$title = $row['title'];
$start = $row['startDate'];
$events = array(
'id' => "$id",
'title' => "$title",
'start' => "$start"
);
}
echo json_encode($events);
?>
That should work for you. If you do not want the even to be all day just add 'allDay' => "" after the start statement.

Resources