I am using DataTables in one of my projects in which I have to fill it with the Oracle query results. I am referring to this document.
Problem:
All the 10 columns returned by query get displayed in row 1 column 1 of the table.
Javascript
$('#inquiryForm').submit(function(){
var cnic = "data="+ $( "#cnicInd" ).val();
//alert(cnic);
$.ajax({
type: "POST",
url: "php/inquiryInd.php",
data: cnic,
success: function(datapage) {
//$("#errmsg").html(data).show();
var datacopy = [[datapage]];
prompt("Result",datacopy);
$('#dataTables-example').DataTable({
responsive: true,
"data": datacopy,
columns: [
{ title: "Policy No." },
{ title: "Client Name" },
{ title: "Gross Premium" },
{ title: "Next Due Date" },
{ title: "Commencement Date" },
{ title: "Cash Value" },
{ title: "Total Amount Paid" },
{ title: "Total Amount Due" },
{ title: "Total unconsumed Amount" },
{ title: "Status" }
]
});
}
});
$('#searchTable').show();
return false;
});
inquiryInd.php
while (($row = oci_fetch_array($stmnt)) != false) {
$result = "";
$result .= '"'.$row['PROPOSAL']."\"";
$result .= ',"'.$row['FULLNAME']."\"";
$result .= ',"'.$row['GROSSPREMIUM']."\"";
$result .= ',"'.$row['NEXTDUEDAT']."\"";
$result .= ',"'.$row['COMMENDATE']."\"";
$result .= ',"'.$row['CASH_VALUE']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_PAID']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_DUE']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_DUE']."\"";
$result .= ',"'.$row['STATUS']."\"";
//$result .= ']';
$dataset .= $result;
//Something like "Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800"
}
Please let me know what am I doing wrong. Any help will be highly appreciated.