I'll get straight to the point. I need to know whether or not, I can force .js
file to read a php
syntax. If so, does anyone of you can educate me on this one? My project is all about parsing a data from the database that will eventually be displayed as a graph. With this I use the ff. code:
data.js
var ganttData = [
{
id: 1, name: "Site Identification", series: [
{ name: "Planned", start: new Date(2018,03,01), end: new Date(2018,03,20) },
{ name: "Actual", start: new Date(2018,03,01), end: new Date(2018,03,15), color: "#ff0000" }
]
},
{
id: 2, name: "Site Evaluation", series: [
{ name: "Planned", start: new Date(2018,04,20), end: new Date(2018,05,10) },
{ name: "Actual", start: new Date(2018,04,21), end: new Date(2018,05,05), color: "#00ff00" },
//{ name: "Projected", start: new Date(2018,00,06), end: new Date(2018,00,17), color: "#e0e0e0" }
]
},
{
id: 3, name: "Approval of MOA with Farmer...", series: [
{ name: "Planned", start: new Date(2018,05,11), end: new Date(2018,05,20) },
{ name: "Actual", start: new Date(2018,05,11), end: new Date(2018,05,21), color: "#ffff00" }
]
},
{
id: 4, name: "Sourcing/Procurement of Planting Material", series: [
{ name: "Planned", start: new Date(2018,05,20), end: new Date(2018,07,18) },
{ name: "Actual", start: new Date(2018,05,20), end: new Date(2018,07,05), color: "#00ff00" }
]
},
{
id: 5, name: "Land Preparation", series: [
{ name: "Planned", start: new Date(2018,07,18), end: new Date(2018,08,26) },
{ name: "Actual", start: new Date(2018,07,18), end: new Date(2018,08,30), color: "#ff0000" }
]
},
{
id: 6, name: "Provision of Access...", series: [
{ name: "Planned", start: new Date(2018,08,26), end: new Date(2018,09,15) },
{ name: "Actual", start: new Date(2018,08,26), end: new Date(2018,09,15), color: "#00ff00" },
//{ name: "Projected", start: new Date(2018,00,06), end: new Date(2018,00,20), color: "#e0e0e0" }
]
},
{
id: 7, name: "Area Isolation...", series: [
{ name: "Planned", start: new Date(2018,09,15), end: new Date(2018,10,05) },
{ name: "Actual", start: new Date(2018,09,16), end: new Date(2018,10,04), color: "#00ff00" },
]
},
{
id: 8, name: "Delivery of Seedlings", series: [
{ name: "Planned", start: new Date(2018,10,01), end: new Date(2018,10,19) },
{ name: "Actual", start: new Date(2018,10,01), end: new Date(2018,10,20), color: "#ff0000" }
]
},
{
id: 9, name: "Inspection & Acceptance", series: [
{ name: "Planned", start: new Date(2018,10,01), end: new Date(2018,10,06) },
{ name: "Actual", start: new Date(2018,10,01), end: new Date(2018,10,06), color: "#00ff00" }
]
},
{
id: 10, name: "Nursery Establishment", series: [
{ name: "Planned", start: new Date(2018,10,01), end: new Date(2018,10,20) },
{ name: "Actual", start: new Date(2018,10,01), end: new Date(2018,10,20), color: "#00ff00" }
]
},
{
id: 8, name: "Transplanting of Seedlings", series: [
{ name: "Planned", start: new Date(2018,10,21), end: new Date(2018,10,26) },
{ name: "Actual", start: new Date(2018,10,21), end: new Date(2018,10,30), color: "#ff0000" }
]
},
{
id: 8, name: "Application of Fertilizers", series: [
{ name: "Planned", start: new Date(2018,11,01), end: new Date(2018,11,06) },
{ name: "Actual", start: new Date(2018,11,01), end: new Date(2018,11,07), color: "#0000ff" }
]
}
];
index.html
<script type="text/javascript" src="data.js"></script>
<script type="text/javascript">
$(function () {
$("#ganttChart").ganttView({
data: ganttData,
slideWidth: 900,
behavior: {
onClick: function (data) {
var msg = "You clicked on an event: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
$("#eventMessage").text(msg);
},
onResize: function (data) {
var msg = "You resized an event: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
$("#eventMessage").text(msg);
},
onDrag: function (data) {
var msg = "You dragged an event: { start: " + data.start.toString("M/d/yyyy") + ", end: " + data.end.toString("M/d/yyyy") + " }";
$("#eventMessage").text(msg);
}
}
});
// $("#ganttChart").ganttView("setSlideWidth", 600);
});
</script>
Using data.js
I was able to display data forcefully because it was hardcoded. But what I need is to use mysql_fetch_array
because I need to parse the data from a database
and not something hardcoded.
Kindly help me on this one? Below is my database structure:
DB1