mysql table to json

I am planning yo use jquery UI Autosuggest for a search I need a json output which can be used by Jquery UI Auto suggest.

heres the database

table name recent_tags

I have tried this first connected to db

$do = mysql_query("SELECT * FROM recent_tags where query like '%" . $_GET['qery'] . "%'"); 
while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
  $row_array['query'] = $row['query'];
echo json_encode($return_arr);

but It's not working.. please guide me..


getting error

Warning: array_push() [function.array-push]: First argument should be an array in /pathto/my/file.php



Try this:

$return_arr = Array();

$query = mysql_real_escape_string($_GET['qery']);
$result = mysql_query("SELECT * FROM recent_tags where query like '%" . $query . "%'"); 

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo json_encode($return_arr);

Need Your Help

How to decode a string on runtime in java?

string encoding get decode

I'm creating email client, when i receive emails from blackberry server it sends file name as "=?utf-8?B?anBlZ2F0dGFjaG1lbnQuSlBFRw==?=" but the original filename was "jpegattachment.JPEG", and som...

CSS : create 2 groups of two input text

html css

I would like to reproduce this interface :

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.