I have try to debug the code saw that after fetching first record error(500 Internal server error) is coming in $row=$conn->fetch_assoc()
here is whole code
connect file
<?php
$conn = new mysqli("localhost","root","","TMS");
if($conn->connect_error){
die("connection Failed");
}
?>
and this main file
include('connect.php');
$data = file_get_contents("php://input");
$mydata = json_decode($data,true);
$search = $mydata['search'];
if(!empty($search))
{
$sql = " SELECT * FROM Information
WHERE gender = 'Male' and (name LIKE '%$search%'
OR age LIKE '%$search%'
OR height LIKE '%$search%'
OR country LIKE '%$search%')";
}else{
$sql = "SELECT * FROM Information";
}
$result = $conn->query($sql);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
$data[]=$row;
}
}
echo json_encode($data);