Search Functionality Not Working
Search Functionality Not Working

<?php
include_once('db.php');
$request=$_POST;
$col= array(
0 => 'id',
1 => 'name',
2 => 'email',
3 => 'phone',
3 => 'city'
);
$sql="select new_test.id,new_test.name,new_test.email,new_test.phone,new_test.city,city_table.emp_id,city_table.emp_city from new_test LEFT JOIN city_table ON new_test.city= city_table.emp_id ";
if(!empty($request['search']['value']))
{
$sql.= " AND (new_test.id Like '" .$request['search']['value']."%' ";
$sql.= " OR new_test.name Like '" .$request['search']['value']."%' ";
$sql.= " OR new_test.email Like '" .$request['search']['value']."%' ";
$sql.= " OR new_test.phone Like '" .$request['search']['value']."%' ";
$sql.= " OR new_test.city Like '" .$request['search']['value']."%' )";
};
$query=mysqli_query($conn,$sql);
$totaldata=mysqli_num_rows($query);
$data=array();
while($row=mysqli_fetch_array($query))
{
$subdata=array(); //Subdata Is Array Name
$subdata[]=$row['id'];
$subdata[]=$row['name'];
$subdata[]=$row['email'];
$subdata[]=$row['phone'];
$subdata[]=$row['emp_city'];
$subdata[]='<button type="button" class="btn btn-success"><a href="edit.php?edit='.$row['id'].'"> EDIT </a></button>';
$subdata[]='<button type="button" class="btn btn-warning"><a href="view.php?del='.$row['id'].'"> DELETE </a></button>';
//$subdata[]='<a href="view.php?del='.$row['id'].' " >Delete</a> ';
$data[]=$subdata;
}
$json_data=array(
'recordsTotal'=> intval($totaldata),
//'recordsFiltered'=> intval($filter),
'data'=> $data
);
echo json_encode($json_data);
<?php
>
?>
This discussion has been closed.
Replies
Per the forum rules please link to a test case showing the issue.
Allan