Advertisement
Guest User

handler.php

a guest
Apr 18th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. // Make a MySQL Connection
  3. mysql_connect("127.0.0.1", "root", "ascent") or die(mysql_error());
  4. mysql_select_db("world") or die(mysql_error());
  5.  
  6. // Get all the data from the "example" table
  7. $escaped_string = mysql_real_escape_string($_GET['dispname']);
  8. $result = mysql_query('SELECT displayid, name FROM item_template WHERE name LIKE "%' . $escaped_string . '%"')
  9. or die(mysql_error());  
  10.  
  11.  
  12. $rows = array();
  13. while($row = mysql_fetch_assoc($result)) {
  14.     $rows[] = array('name' => $row['name'], 'id' => $row['displayid']);
  15. }
  16. header('Content-Type: application/json');
  17. echo json_encode($rows);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement