Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $dbh;
- $countries = array();
- $term = '';
- if (isset($_GET['term'])) {
- $term = trim(strip_tags($_GET['term']));
- }
- if (isset($term)) {
- $stmt = $dbh->prepare("SELECT name FROM countries WHERE name LIKE CONCAT('%', :term, '%') ORDER BY name ASC");
- $stmt->bindParam(':term', $term, PDO::PARAM_STR);
- if ($stmt->execute()) {
- while ($row = $stmt->fetch()) {
- $countries[] = $row['name'];
- }
- }
- }
- echo json_encode($countries);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement