Retrieve table data from oracle database into datatable using PHP
Retrieve table data from oracle database into datatable using PHP

I'm trying to retrieve table data from oracle database into datatable using PHP. But i'm strugling with my datatable appears "No data available in table". Yes I see several posts that newer versions of the datatable is not compatible with oracle. How do i solve this issue?
fetch_data(); function fetch_data(){ $(document).ready(function() { $('#customer_table').DataTable({ "processing" : true, "serverside" : true, "ajax" : { url: "connect.php", type: "POST", data: {action: 'fetch'}, error: function(xhr, error, thrown) { console.log("AJAX error:", error, thrown); }, }, "columns": [ { data: 'FIRSTNAME' }, { data: 'LASTNAME' }, { data: 'NIC' } ], }); }); }if (!$conn)
{
echo 'you fail';
}else
{
echo "success!";
}
// execute an SQL query
if(isset($_POST["action"]))
{
if($_POST["action"] == 'fetch')
{
$query = "SELECT FIRSTNAME,LASTNAME,NIC FROM customer where NIC='830380124V'";
$statement = oci_parse($conn, $query );
$result = oci_execute($statement);
if (!$result) {
$error_message = oci_error($statement)['message'];
echo "Error executing SQL query: $error_message";
exit();
}
$data = array();
// Loop through the results and add them to the array
while ($row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS)) {
$data[] = $row;
}
// close the database connection
oci_close($conn);
if (count($data) == 0) {
echo "No rows returned from SQL query.";
exit();
}
// Convert the data to JSON format
$json_data = json_encode(array("data" => $data));
echo $json_data;
}
}
This discussion has been closed.
Answers
please help