Using LEFT JOIN inside datatable server side script

dear all, i'll take some data from the database. and join two tables.the code like:

SELECT DATE(A.Inspection_datetime) AS Date, 
  A.Model, 
  COUNT(A.Serial_number) AS Qty, 
  B.Name 
FROM inspection_report AS A 
LEFT JOIN Employee AS B ON A.NIK = B.NIK 
 GROUP BY A.Model, A.Serial_number

i want show this data using jQuery dataTable.I have tried to modify at dataTable's server side script.I have changed at this part:

$sWhere = " WHERE Inspection_datetime LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' 
  OR Model LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' 
  OR Serial_number LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' 
  OR NIK LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' ";

$sQuery = "SELECT id, 
  DATE(A.Inspection_datetime) AS Date, 
  A.Model, 
  COUNT(A.Serial_number) AS Qty, 
  B.Name 
  FROM inspection_report AS A 
  LEFT JOIN Employee AS B ON A.NIK = B.NIK .$sWhere.$sOrder.$sLimit";

$sOutput .= "[";
  $sOutput .= '"'.addslashes($aRow['id']).'",';
  $sOutput .= '"'.addslashes($aRow['Date']).'",';
  $sOutput .= '"'.addslashes($aRow['Model']).'",';
  $sOutput .= '"'.addslashes($aRow['Qty']).'",';
  $sOutput .= '"'.addslashes($aRow['Name']).'"';
  $sOutput .= "],";

i want the result like my mysql code, but this make like:

{"sEcho":1,"iTotalRecords":2,"iTotalDisplayRecords":2, "aaData":[["42","","bar","","Steve"]]}

Answers


what have I done? I was very careless. these are to be replaced.

$sOutput .= "[";
                $sOutput .= '"'.addslashes($aRow['id']).'",';
                $sOutput .= '"'.addslashes($aRow['Date').'",';
                $sOutput .= '"'.addslashes($aRow['Model']).'",';
                $sOutput .= '"'.addslashes($aRow['Qty']).'",';
                $sOutput .= '"'.addslashes($aRow['Name']).'"';
                $sOutput .= "],";

Need Your Help

How to get "onclick" after click on div in link?

javascript jquery

How to get "onclick" after click on div in link on jquery?

R.menu cannot be resolved

java android

So I am going through the Android development tutorial and I have run into an early problem when creating menus. I created a folder under res called menu and put in game_menu.xml as I was told.