search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Database

Related article: AngularJS Doctor Appointment Scheduling Tutorial (PHP)
Asked by Anonymous
6 years ago.

How can I connect it to database?

Thanks

Answer posted by Ramgaard
6 years ago.

Javascript can't connect directly to a database, but it can request data from external pages, files.

I use PHP, and a MS SQL database.

I have created an API were I can request data for my scheduler,

So, my PHP file, "get_task.php", creates an JSON file that I can call from my calendar view.

[JSON data example]
[{start:"2018-06-01",start:"2018-06-05",id:5,resource:"G1",html:"<b>some html</b>",htmlcolor:"#c3c3c3"},{start:"2018-06-08",start:"2018-06-10",id:6,resource:"G3",html:"<b>some html</b>",htmlcolor:"#c3c3c3"}]

DayPilot / Jquery function to add tasks:

$.getJSON( "api/get_tasks.php", function(data) {
$.each(data, function( index, value ) {
var e = new DayPilot.Event({
start: value.datefrom,
end: value.dateto,
id: value.taskid,
resource: value.resource,
html: value.html,
barColor: value.htmlcolor,
});
dp.events.add(e);
});
});

I hope it can help you in the right direction.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.