Uncaught type error: Cannot Read property error of null
Uncaught type error: Cannot Read property error of null
I am Satya, trying to get the data from the database and displaying the data in the Jquery datatables, I have included my code below, here the scenario is when I am trying to get sql query data without any where clause I am able to display data in datatable, when I included where clause it is showing Cannot read property error of null, I tried a lot to fix that, even I getting data from php to javascript page through ajax but it is not getting data to datatables, here is my code
Jquery:
$("
<
table id='example' class='display' cellspacing='0' width='100%' style:'text-align:center;'>"
+"<thead>"
+"<tr>"
+"<th>EID</th>"
+"<th>EMICH_EMAIL</th>"
+"<th>FIRSTNAME</th>"
+"<th>LASTNAME</th>"
+"<th>SIGN_IN</th>"
+"<th>SIGN_OUT</th>"
+"<th>DURATION</th>"
+"</tr>"
+"</thead>"
+"<tbody>").appendTo('#table-section');
$('#example').dataTable({
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath":"http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"
},
"bProcessing": false,
"sAjaxDataProp":'',
"sAjaxSource":"fetchdata.php"
});
PHP:
<?php
include 'dataconnection.php';
$user_id=$_POST['eid'];
$from=$_POST['startdate'];
$to=$_POST['enddate'];
$students_data="select st.EID,st.emich_email,firstname,lastname,sign_in,sign_out,SEC_TO_TIME(TIME_TO_SEC(timediff(sign_out,sign_in))) AS totalduration from student_details st INNER JOIN scans sc ON st.emich_email = sc.emich_email where st.EID ='$user_id'";
$students_data_query=mysqli_query($connection,$students_data);
if($students_data_query)
{
while($row = mysqli_fetch_array($students_data_query)){
$output[]=array($row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6]);
}
echo json_encode($output);
//echo $user_id;
}
else
echo die("The error is:".mysqli_error($connection));
?>
php ajax datatables jquery-datatables
share|edit|delete|flag
asked 1 hour ago
Karthik Achanta
134
add a comment