Advertisement
Guest User

search.php

a guest
Mar 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $dbHost = 'localhost';
  5. $dbUsername = 'root';
  6. $dbPassword = '';
  7. $dbName = 'pokemon';
  8.  
  9. $db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
  10.  
  11. $searchTerm = $_GET['term'];
  12.  
  13. $query = $db->query("SELECT * FROM pokemon WHERE Pokemon LIKE '".$searchTerm."%' ORDER BY Pokemon ASC");
  14. while ($row = $query->fetch_assoc()) {
  15. $data[] = $row['Pokemon'];
  16. }
  17. //return json data
  18. echo json_encode($data);
  19.  
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement