Domain: amberpublishers.in
Server Adress: 86.38.243.169
privdayz.com
<?php
session_start();
require('../data_base_connection_xyzabc.php');
require('../PHPHelper.php');
header("Cache-Control: no-cache, must-revalidate");
if (isset($_POST['isset_datatable_student_data'])) {
$table_name = realEscape('db_table');
$columns = $_POST['search_col'];
// Define the search term
$searchTerm = $_POST['search']['value'];
// Define the SQL query
$sql = "SELECT * FROM " . $table_name;
// Apply search term
if (!empty($searchTerm)) {
$sql .= " WHERE ";
$searchTerms = array();
foreach ($columns as $column) {
$searchTerms[] = $column . " LIKE '%" . mysqli_real_escape_string($conn, $searchTerm) . "%'";
}
$sql .= implode(" OR ", $searchTerms);
}
// Execute the query
$result = mysqli_query($conn, $sql);
// Get total number of records
$totalRecords = mysqli_num_rows($result);
// Apply pagination
$start = $_POST['start'];
$length = $_POST['length'];
$sql .= " LIMIT " . $start . ", " . $length;
// Execute the query with pagination
$result = mysqli_query($conn, $sql);
// Create an empty array to store the table data
$data = array();
// Fetch the data and add it to the array
while ($row = mysqli_fetch_assoc($result)) {
array_push($data, $row);
}
// Prepare the response
$response = array(
"draw" => intval($_POST['draw']),
"recordsTotal" => intval($totalRecords),
"recordsFiltered" => intval($totalRecords),
"data" => $data
);
// Send the response as JSON
echo json_encode($response);
}
