Autocomplete Textbox results based from SQL database

前端 未结 5 991
情深已故
情深已故 2020-12-16 06:16

I\'m trying to create an auto-complete function into a textbox but the result should come from my SQL database.

Here\'s the code that i\'m trying to configure:
<

5条回答
  •  长情又很酷
    2020-12-16 06:26

    When a string is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data.

    source: "autocomplete.php"
    

    Therefore you need to return a JSON object.

    $json = false;
    while($row=mysqli_fetch_array($result))
    {
        $json[] = array(
            'name' => $row['name']
        );
    }
    echo json_encode($json);
    

提交回复
热议问题