I have a code that fetch all the data in MS Access database in php and its working.
$conn = odbc_connect('pivot_test','','') or die ("Error in connection");
$sql = "select * from empDetails";
$rs = odbc_exec($conn,$sql);
if (!$rs)
{ exit ("Error in Sql");}
echo "<table><tr>";
echo "<th>id</th>";
echo "<th>year</th>";
echo "<th>month</th>";
echo "<th>empName</th>";
echo "<th>empPos</th>";
echo "<th>numMc</th>";
echo "<th>numLeave</th></tr>";
while (odbc_fetch_row($rs))
{
$id = odbc_result($rs,"id");
$year = odbc_result($rs,"year");
$month = odbc_result($rs,"month");
$empName = odbc_result($rs,"empName");
$empPose = odbc_result($rs,"empPos");
$numMc = odbc_result($rs,"numMc");
$numLeave = odbc_result($rs,"numLeave");
}
odbc_close($conn);
echo"</table>";
?>
But now I need to store all the data in the dataset something like this:
var pivot_dataset = [
{"id": 1, "year": 2014 , "month": "JAN", "empName": "David", "empPos": "engineer", "numMc": 1, "numLeave": 2},
];
How to do this?please advise.