PHP - 在数组中显示数据

The following code is referenced in an autocomplete object I have on my page

<?php
require('json.php');
error_reporting(E_ALL);
mysql_connect("localhost", "root", "") or
    die("Could not connect: " . mysql_error());
mysql_select_db("timetable") or die("No such database");
$sql = sprintf("SELECT id,dsc FROM module WHERE dsc LIKE '%%%s%%'",
               mysql_real_escape_string($_REQUEST['term']));
$result = mysql_query($sql)
  or die(mysql_error());
$all = array();
while ($row = mysql_fetch_array($result))
    $all[] = array('value'=>$row[1],'label'=>$row[1]);
print json_encode($all);
?>

The autocomplete is working fine but there is no option to then display the data. Can anyone see what I'm doing wrong

Could you try with this? it may helps you

 <?php
    require('json.php');
    error_reporting(E_ALL);
    mysql_connect("localhost", "root", "") or
        die("Could not connect: " . mysql_error());
    mysql_select_db("timetable") or die("No such database");
    $sql = sprintf("SELECT id,dsc FROM module WHERE dsc LIKE '%%%s%%'",
                   mysql_real_escape_string($_REQUEST['term']));
    $result = mysql_query($sql)
      or die(mysql_error());
    $all = array();
    while ($row = mysql_fetch_array($result))
    {
    array_push($all,array('value'=>$row[1],'label'=>$row[1]));
    }
    echo(json_encode($all));
    ?>

Try this JS:

$(function(){
  $('#who').autocomplete({
    source: function() {
      $.get('scripts/searchstaff.php', function(data) {
        $(target).text(data);
        return data;
      }
    }
  });
});

Autocomplete uses the echo/return from your php just internally for itself, you have to catch the data and write it out clientside.

Note: data would be a json string, you can parse it into an object with JSON.parse(data), then do whatever you want with the object.