Closed

JSON/PHP Dynamic Feed to fill calendar events

This project was awarded to moovmoov1 for $50 USD.

Get free quotes for a project like this
Employer working
Awarded to:
Skills Required
Project Budget
$30 - $60 USD
Total Bids
5
Project Description

The attached zip file is the javascript calendar I am implementing into a page in my site.

It needs to use the json method as described at: [url removed, login to view]

The calendar javascript on the main PHP page ([url removed, login to view]) needs to be:

<script type='text/javascript'>

$(document).ready(function() {

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,

events: "[url removed, login to view]",

eventDrop: function(event, delta) {
alert([url removed, login to view] + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},

loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}

});

});

</script>
javascript call function for the html is:

<body>
<div id='loading' style='display:none'>loading...</div>
<div id='calendar'></div>
<body>


The text that I have so far is: ([url removed, login to view])
<?php
$con = mysql_connect('localhost', 'root', 'pass');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("database", $con);

$sql="SELECT * FROM approviderbooked WHERE comp_id = 'zstone'";

$result = mysql_query($sql);

do {

$classname = $row['class_name'];
$time = $row['b_from'];
sscanf($time, "%d :%d", $hour, $min );//start time
$timee = $row['b_to'];
sscanf($timee, "%d :%d ", $houre, $mine );//end time

$bookday = $row['book_day'];
sscanf($bookday, "%d/%d/%d", $month, $day, $year );//start date
$bookdaye = $row['book_day'];
sscanf($bookdaye, "%d/%d/%d", $month, $day, $yeare );//end date



echo json_encode(array(

array(
'title' => $classname,
'start' => "$year-$month-$day $hour:$min:00Z",
'end' => "$year-$month-$day $houre:$mine:00Z",
'allDay' => false
)
));
} while ($row = mysql_fetch_assoc($result));
mysql_close($con);
?>


create table data for sql>>>>

-- --------------------------------------------------------

--
-- Table structure for table `approviderbooked`
--

CREATE TABLE `approviderbooked` (
`b_hour_id` int(10) NOT NULL auto_increment,
`comp_id` varchar(25) NOT NULL,
`j_id` int(10) NOT NULL,
`class_name` varchar(25) NOT NULL,
`s_id` int(10) NOT NULL,
`book_day` varchar(10) NOT NULL,
`p_job_duration` decimal(3,2) NOT NULL,
`b_from` time NOT NULL,
`b_to` time NOT NULL,
`b_class_count` varchar(3) NOT NULL,
`b_class_avail` varchar(1) NOT NULL default '1',
`p_id` int(10) NOT NULL,
PRIMARY KEY (`b_hour_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10003 ;

--
-- Dumping data for table `approviderbooked`
--

INSERT INTO `approviderbooked` VALUES (10000, 'zstone', 1, 'Hatha Yoga', 1, '11/11/2011', [url removed, login to view], '16:30:00', '17:30:00', '1', '1', 10);
INSERT INTO `approviderbooked` VALUES (10001, 'zstone', 1, 'Ashtonga Yoga', 1, '11/11/2011', [url removed, login to view], '16:00:00', '16:30:00', '10', '1', 16);
INSERT INTO `approviderbooked` VALUES (10002, 'zstone', 2, 'Tai Chi', 2, '11/12/2011', [url removed, login to view], '17:00:00', '18:00:00', '3', '1', 10);

<<<<>>>>>>>

current json output is

[{"title":null,"start":"-- ::00Z","end":"-- ::00Z","allDay":false}][{"title":"Hatha Yoga","start":"2011-11-11 16:30:00Z","end":"2011-11-11 17:30:00Z","allDay":false}][{"title":"Ashtonga Yoga","start":"2011-11-11 16:0:00Z","end":"2011-11-11 16:30:00Z","allDay":false}][{"title":"Tai Chi","start":"2011-11-12 17:0:00Z","end":"2011-11-12 18:0:00Z","allDay":false}]

output needs to be (notice the times $min that are 00 changed to 0 in the above - also ][ is , between outer []

[{"title":null,"start":"-- ::00Z","end":"-- ::00Z","allDay":false},{"title":"Hatha Yoga","start":"2011-11-11 16:30:00Z","end":"2011-11-11 17:30:00Z","allDay":false},{"title":"Ashtonga Yoga","start":"2011-11-11 16:00:00Z","end":"2011-11-11 16:30:00Z","allDay":false},{"title":"Tai Chi","start":"2011-11-12 17:00:00Z","end":"2011-11-12 18:00:00Z","allDay":false}]

or another option using the json / feed method

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online