Skip to content

Instantly share code, notes, and snippets.

@jjulian
Created April 5, 2010 20:02
Show Gist options
  • Save jjulian/356788 to your computer and use it in GitHub Desktop.
Save jjulian/356788 to your computer and use it in GitHub Desktop.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db('myapp_development');
$query = empty($_GET['query']) ? '' : $_GET['query'];
$rows = mysql_query("SELECT * FROM users where username like '%$query%' ORDER BY created_at DESC");
while ($obj = mysql_fetch_object($rows)) {
$arr[] = $obj;
}
header('Content-type: application/json');
echo '{rows:' . json_encode($arr) . '}';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment