File: /var/www/nclive/technc/exam_cutoff_list_data.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include 'config.php';
$requestData = $_REQUEST;
$columns = array(
0 => 'id',
1 => 'exam_id',
2 => 'exam_name',
3 => 'year',
4 => 'obc',
5 => 'ex_servicemen',
6 => 'comment',
7 => 'added_date',
8 => 'display_order',
9 => 'status'
);
$getDataQuery = "SELECT cutoff.id,cutoff.exam_id,cutoff.year,cutoff.obc,cutoff.ex_servicemen,cutoff.comment,cutoff.status,cutoff.added_date,cutoff.display_order,exams.exam_name FROM sp_exam_cutoff AS cutoff LEFT JOIN sp_exam AS exams ON exams.exam_id=cutoff.exam_id WHERE cutoff.exam_id !='' ";
$getData=$db->prepare($getDataQuery);
$getData->execute();
$totalData = $getData->rowCount();
$totalFiltered = $totalData;
$searchTerms = "";
if (!empty($requestData['search']['value'])) {
$searchTerms .= " AND ( cutoff.exam_id LIKE '" . $requestData['search']['value'] . "%' ";
$searchTerms .= " OR cutoff.year LIKE '%" . $requestData['search']['value'] . "%' ";
$searchTerms .= " OR cutoff.obc LIKE '%" . $requestData['search']['value'] . "%' ";
$searchTerms .= " OR cutoff.ex_servicemen LIKE '%" . $requestData['search']['value'] . "%' ";
$searchTerms .= " OR exams.exam_name LIKE '%" . $requestData['search']['value'] . "%' ) ";
}
$getDataQuery = "SELECT cutoff.id,cutoff.exam_id,cutoff.year,cutoff.obc,cutoff.ex_servicemen,cutoff.comment,cutoff.status,cutoff.added_date,cutoff.display_order,exams.exam_name FROM sp_exam_cutoff AS cutoff LEFT JOIN sp_exam AS exams ON exams.exam_id=cutoff.exam_id WHERE cutoff.exam_id !='' $searchTerms";
$getData=$db->prepare($getDataQuery);
$getData->execute();
$totalFiltered = $getData->rowCount();
$getDataQuery .= " ORDER BY " . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . ", " . $requestData['length'] . " ";
$getData=$db->prepare($getDataQuery);
$getData->execute();
$data = array();
while ($querydata = $getData->fetch()) {
$nestedData = array();
$nestedData["id"] = $querydata['id'];
$nestedData["exam_id"] = $querydata['exam_id'];
$nestedData["exam_name"] = $querydata['exam_name'];
$nestedData["year"] = $querydata['year'];
$nestedData["obc"] = $querydata['obc'];
$nestedData["ex_servicemen"] = $querydata['ex_servicemen'];
$nestedData["comment"] = $querydata['comment'];
$nestedData["added_date"] = $querydata['added_date'];
$nestedData["display_order"] = $querydata['display_order'];
$nestedData["status"] = $querydata['status'];
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval($requestData['draw']),
"recordsTotal" => intval($totalData),
"recordsFiltered" => intval($totalFiltered),
"data" => $data
);
echo json_encode($json_data);
?>