How do I encode an input to json for the jquery ui autocomplete?
I was already able to implement the autocomplete, it's just that what I wan to do is use the json_encode function of php. 

Here's my current code:

    <?php
    
    $host = "localhost"; 
    $user = "root"; 
    $password = ""; 
    $db = "isproj2"; 
    
    // open connection 
    $connection = mysql_connect($host, $user, $password) or die ("Unable to connect!"); 
    
    // select database 
    mysql_select_db($db) or die ("Unable to select database!"); 
    $text = mysql_real_escape_string($_GET['term']);
    
    
    $query = "Select SupplierName, SupplierID from tbl_supplier where SupplierName LIKE '%$text%'";
    $result = mysql_query($query);
    $json = '[';
    $first = true;
    while($row = mysql_fetch_array($result))
    {
        if (!$first) { $json .=  ','; } else { $first = false; }
        $json .= '{"label":"'.$row['SupplierName'].'","value":"'.$row['SupplierID'].'" }';
    }
    $json .= ']';
    echo $json;
    ?>

Sir/Ma'am your answers would be of great help. Thank you++
How do I encode an input to json for the jquery ui autocomplete?
===

I was already able to implement the autocomplete, it's just that what I wan to do is use the json_encode function of php. 

Here's my current code:

    <?php
    
    $host = "localhost"; 
    $user = "root"; 
    $password = ""; 
    $db = "isproj2"; 
    
    // open connection 
    $connection = mysql_connect($host, $user, $password) or die ("Unable to connect!"); 
    
    // select database 
    mysql_select_db($db) or die ("Unable to select database!"); 
    $text = mysql_real_escape_string($_GET['term']);
    
    
    $query = "Select SupplierName, SupplierID from tbl_supplier where SupplierName LIKE '%$text%'";
    $result = mysql_query($query);
    $json = '[';
    $first = true;
    while($row = mysql_fetch_array($result))
    {
        if (!$first) { $json .=  ','; } else { $first = false; }
        $json .= '{"label":"'.$row['SupplierName'].'","value":"'.$row['SupplierID'].'" }';
    }
    $json .= ']';
    echo $json;
    ?>

Sir/Ma'am your answers would be of great help. Thank you++