Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--- auto complete html --->
- <!DOCTYPE html>
- <html>
- <head>
- <title>Autocomplete</title>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
- </head>
- <body>
- <br /><br />
- <div class="container" style="width:600px;">
- <label>Pessoa</label>
- <input type="text" name="Pessoa" id="Campo_Pesquisa" class="form-control input-lg" autocomplete="off" placeholder="Digite o nome da pessoa" />
- <label>Id</label>
- <input type="text" name="Id" id="Id_Pessoa" class="form-control input-lg" autocomplete="off" placeholder="Id da pessoa" />
- </div>
- <script>
- $(document).ready(function(){
- $('#Campo_Pesquisa').typeahead({
- source: function(query, result)
- {
- $.ajax({
- url:"BuscaPessoa.php",
- method:"POST",
- data:{query:query},
- dataType:"json",
- success:function(data)
- {
- result($.map(data, function(item){
- return item;
- }));
- }
- })
- }
- });
- });
- </script>
- </body>
- </html>
- <!--- auto complete html --->
- <!--- auto complete php consulta BuscaPessoa.php --->
- <?php
- header('Content-Type: application/json; charset=utf-8');
- require "../../Includes/Config/ConfigSystem.php";
- require "../../Includes/Functions/Seguranca.php";
- require "../../Includes/Databases/MySQL_Default_System.php";
- $SQL_Busca = "
- SELECT SQL_CACHE Nome_Religioso, ID_Pessoa
- FROM pessoas
- WHERE Nome_Religioso
- LIKE '%$PalavraPraBusca%'
- ";
- $Busca = $ConnectionSystem->query($SQL_Busca) or die($ConnectionSystem->error);
- $DadosAutoComplete = array();
- if ($Busca->num_rows > 0) {
- while($Dados = $Busca->fetch_assoc()) {
- $DadosAutoComplete[]= $Dados['Nome_Religioso'];
- }
- echo json_encode($DadosAutoComplete,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
- }
- $ConnectionSystem->close();
- ?>
- <!--- auto complete php consulta BuscaPessoa.php --->
Add Comment
Please, Sign In to add comment