저는 Satya입니다. 데이터베이스에서 데이터를 가져 와서 Jquery 데이터 테이블에 데이터를 표시하려고합니다.Jquery Datatables에서 NULL 속성을 읽을 수 없습니다.
아래 코드를 포함 시켰습니다. 여기서 시나리오는 where 절없이 SQL 쿼리 데이터를 얻으려고 할 때입니다. 나는 데이터 테이블에 데이터를 표시 할 수 있는데, 여기에 표시되는 부분은 Cannot read property error of null
이고, 심지어는 PHP에서 아약스를 통해 PHP로 데이터를 가져 오는 데 많은 노력을했지만 데이터 테이블에 데이터를 가져 오지 않습니다. 내 코드 :
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));
?>
당신은 NULL 값을 처리해야합니다. 당신의 질의에'IFNULL()'함수를 넣으십시오. –
안녕하세요 페르난도 나는 데이터베이스에서 데이터를 가져온 후에도 데이터에 NUALL 값을 갖고 있지 않습니다. 단지 화면에서 경고하고 null 값을 찾지 못했지만 데이터가 datatables에 표시되지 않습니다. 내 질문에 시간을내어 주셔서 대단히 감사합니다. –
Hummm ... 이해합니다 .. JSON의 형식이 어떻게됩니까? –