fetch.php
//fetch.php
$connect = mysqli_connect("localhost", "kayit_ol", "1234567899", "kayit_ol");
$columns = array('id', 'adiniz', 'soyadiniz','cinsiyet', 'sehirler', 'eposta','tarih_yilaygun');
$query = "SELECT * FROM basvuru WHERE ";
if($_POST["is_date_search"] == "yes")
{
$query .= 'tarih_yilaygun BETWEEN "'.$_POST["start_date"].'" AND "'.$_POST["end_date"].'" AND ';
}
if(isset($_POST["search"]["value"]))
{
$query .= '
(id LIKE "%'.$_POST["search"]["value"].'%"
OR sehirler LIKE "%'.$_POST["search"]["value"].'%"
OR eposta LIKE "%'.$_POST["search"]["value"].'%"
OR tarih_yilaygun LIKE "%'.$_POST["search"]["value"].'%")
';
}
if(isset($_POST["order"]))
{
$query .= 'ORDER BY '.$columns[$_POST['order']['0']['column']].' '.$_POST['order']['0']['dir'].'
';
}
else
{
$query .= 'ORDER BY id DESC ';
}
$query1 = '';
if($_POST["length"] != -1)
{
$query1 = 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}
$number_filter_row = mysqli_num_rows(mysqli_query($connect, $query));
$result = mysqli_query($connect, $query . $query1);
$data = array();
while($row = mysqli_fetch_array($result))
{
$sub_array = array();
$sub_array[] = $row["id"];
$sub_array[] = $row["adiniz"];
$sub_array[] = $row["soyadiniz"];
$sub_array[] = $row["cinsiyet"];
$sub_array[] = $row["sehirler"];
$sub_array[] = $row["eposta"];
$sub_array[] = $row["tarih_yilaygun"];
$data[] = $sub_array;
}
function get_all_data($connect)
{
$query = "SELECT * FROM basvuru";
$result = mysqli_query($connect, $query);
return mysqli_num_rows($result);
}
$output = array(
"draw" => intval($_POST["draw"]),
"recordsTotal" => get_all_data($connect),
"recordsFiltered" => $number_filter_row,
"data" => $data
);
echo json_encode($output);
?>