<?php mysql_connect("localhost","root","");
mysql_select_db("web-school");
?>
<?php
$data = '';
$i = 0;

$query = "
    SELECT
        `course_id`, `batch`, `start_date`, `end_date`, `org_id`, `id`
    FROM
        `batch`
";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
    $data .= '
        data['.$i.'] = {
            title: "'.$row['course_id'].'",
            duration: "'.$row['batch'].'",
            percentComplete: "'.$row['start_date'].'",
            start: "'.$row['end_date'].'",
            finish: "'.$row['org_id'].'",
            effortDriven: "'.$row['id'].'"
        };
    ';

    $i++;
}
?>	
<script type="text/javascript">
    var grid;

    var columns = [
        {id:"title", name:"Title", field:"title"},
        {id:"duration", name:"Duration", field:"duration"},
        {id:"%", name:"% Complete", field:"percentComplete"},
        {id:"start", name:"Start", field:"start"},
        {id:"finish", name:"Finish", field:"finish"},
        {id:"effort-driven", name:"Effort Driven", field:"effortDriven"}
    ];

    var options = {
        enableCellNavigation: false,
        enableColumnReorder: false
    };

    $(function() {
        var data = [];
        <? echo $data; ?> //This is where we echo the PHP variable $data which contains our JavaScript array as a string.

        grid = new Slick.Grid($("#myGrid"), data, columns, options);
    })
</script>