<?php

include('../../../../r_constants.php');
$res = mysql_connect(MAIN_DBHOST,MAIN_DBUNAME,MAIN_DBPASS);
mysql_select_db(MAIN_DBNAME,$res);

$q = !empty($_REQUEST['query']) ? $_REQUEST['query'] : '';
$sql = "SELECT tag_name FROM pr8_tags WHERE tag_name like '".$q."%'";
$res = mysql_query($sql);
$result = array();
while( list($tag_name) = mysql_fetch_array($res) ){
  $result[]=$tag_name;
}
$test=array('query'=>$_GET['query'],'suggestions'=>$result);
 echo json_encode($test);
?>
