escape_string(trim($_POST['inputSearchVal'])); } else { $json_array[] = ''; echo json_encode($json_array); exit(); } // query to database $member_q = $dbs->query("SELECT member_id, member_name FROM member WHERE member_id LIKE '%$searchVal%' OR member_name LIKE '%$searchVal%' LIMIT 10"); if ($member_q->num_rows < 1) { $json_array[] = 'NO DATA FOUND'; echo json_encode($json_array); exit(); } // loop data while ($member_d = $member_q->fetch_row()) { $json_array[] = $member_d[0].' <'.$member_d[1].'>'; } // encode to JSON array if (!function_exists('json_encode')) { echo json_encode($json_array); exit(); } echo json_encode($json_array);