I am a beginner and newbie to this site, I am stuck with my project in hand and would really appreciate some help.

I am using a JQuery plugin written by a third party.
There are 3 javascripts 
i.e. a.js, b.js, c.js

**a.js** is the framework that b.js works under

**b.js** contains a form builder, it contains a function that calls on a JSON array named **selectionOpt** stored in **c.js**

function in b.js is as below

```
createChildren: function () {
        this._super();
        var self = this;

        this.comboselected = new DrawComboBox({
            styles: "comboselected",
            data: Draw.selectionOpt1,
            onChange:function () {
                self.comboselected = self.comboselected.value();
                    }       

   };
 });

```

JSON array in c.js looks like this

```
Draw.selectionOpt1 = [
    {"Id": 1,"data": Blue,"label": "Blue","quantity": 100},
    {"Id": 2,"data": Red,"label": "Red","quantity": 100},
    {"Id": 3,"data": Green,"label": "Green","quantity": 100},
    {"Id": 4,"data": White,"label": "White","quantity": 100},
    ...etc..
    ...etc..
    }
    ];

```

I would like to have the raw data stored in the database (MySQL) instead of c.js
I am struggling with this at the moment. 
I have got a PHP script i.e. api.php written as below 

```
<?php 

 include 'DB.php';
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);

 $result = mysql_query("SELECT * FROM $tableName");          //query
$colouroptions = Array();                          //fetch result    

while( $obj = mysql_fetch_row($result) ) {  
 $colouroptions[] = $obj;  
}

 echo json_encode($colouroptions);  

?>

```

this script returns the following result

```
[["1","Red","Red","100"],["2","Blue","Blue","100"],["3","Green","Green","100"], etc, etc.,...[etc, etc, etc, etc]]

```

Q1: How can I get fetch the data from MySQL and encode it in the desire format?

```
{"Id": 1,"data": Blue,"label": "Blue","quantity": 100},
{"Id": 2,"data": Red,"label": "Red","quantity": 100},
{"Id": 3,"data": Green,"label": "Green","quantity": 100},

etc etc etc

```

Q2: How can I call the JSON array generated from api.php from b.js? or do I need to feed it back to c.js first? How can it be done? 

Thank you in advanced.