Autocomplete Textbox results based from SQL database

前端 未结 5 984
情深已故
情深已故 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:44

    Solved my problem.

    Have the script like this:

    
    
    
    
    
    
    

    And autocomplete.php (where we will get the data to fill the autocomplete input field):

    prepare("SELECT description FROM table"); /* START PREPARED STATEMENT */
      $stmt->execute(); /* EXECUTE THE QUERY */
      $stmt->bind_result($description); /* BIND THE RESULT TO THIS VARIABLE */
      while($stmt->fetch()){ /* FETCH ALL RESULTS */
        $description_arr[] = $description; /* STORE EACH RESULT TO THIS VARIABLE IN ARRAY */
      } /* END OF WHILE LOOP */
    
      echo json_encode($description_arr); /* ECHO ALL THE RESULTS */
    
    ?>
    

提交回复
热议问题