I am returning a JSON encoded array: echo(json_encode($data));
from php and I would like it to populate the suggest box from JQuery autocomplete. I\'m using thi
Somthing like this is the best way. json_encode do all work for you.
$result = $_mysqli->query(...);
$rs = array();
$pos = 0;
while($row = $result->fetch_assoc()){
$rs[$pos]["n1"] = $row["n1"];
$rs[$pos]["n2"] = $row["n2"];
...
$rs[$pos++]["nn"] = $row["nn"];
}
header('Content-type: application/json');
echo json_encode($rs);