Aqui vou compartilhar um banco de dados útil que é a lista de códigos STD da Índia em MYSQL e EXCEL com o script STD Code Finder em PHP, MYSQL, JQUERY.
Se você está planejando criar qualquer site baseado em telecomunicações, pode ajudá-lo, aqui eu compartilhei banco de dados completo com script, no script do localizador de código STD eu usei o recurso de preenchimento automático do jquery, você pode ler o tutorial sobre como criar preenchimento automático/automático -sugerir

Então vamos começar o tutorial
Crie seu arquivo html. com algum css e javascript necessário, não se esqueça de incluir a biblioteca jquery.
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>INDIA, STD Code Finder Script in PHP, MYSQL, JQUERY</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<style>
.ui-autocomplete-loading {
background: white url("img/ui-anim_basic_16x16.gif") right center no-repeat;
}
.ui-autocomplete {
max-height: 300px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
}
/* IE 6 doesn't support max-height
* we use height instead, but this forces the menu to always be this tall
*/
* html .ui-autocomplete {
height: 100px;
}
</style>
</head>
<body>
<h3>INDIA, STD Code Finder Script in PHP, MYSQL, JQUERY</h3>
<div class="ui-widget">
<input type="text" id="std" name="std" placeholder="Type city name or std code" style="width:550px;"><br/>
<span style="color:red">* Enter atleast 3 character..!! </span>
</div>
<br/><br/>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#std" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "request.php",
dataType: "json",
data: {
q: request.term
},
success: function( data ) {
response( data );
}
});
},
minLength: 3,
select: function( event, ui ) {
// do something on select event
console.log(ui.item); // ui.item is responded json from server
},
open: function() {
// D0 something on open event.
},
close: function() {
// Do omething on close event
}
});
});
</script>
</body>
</html> |
Criar arquivo do servidor para buscar dados do banco de dados e retornar no formato json.
<?php
$hostname = "localhost";
$username = "username";
$password = "db-password";
$dbname = "database-name";
$q = $_GET['q'];
if(isset($q) || !empty($q)) {
$con = mysqli_connect($hostname, $username, $password, $dbname);
$query = "SELECT * FROM stdcodes WHERE CONCAT(city, ' ', stdcode) LIKE '%$q%'";
$result = mysqli_query($con, $query);
$res = array();
while($resultSet = mysqli_fetch_assoc($result)) {
$res[$resultSet['id']] = $resultSet['city'].", STD-CODE: ".$resultSet['stdcode'];
}
if(!$res) {
$res[0] = 'Not found!';
}
echo json_encode($res);
}
?> |
Use o botão abaixo para ver a demonstração ao vivo e baixar o código-fonte com o banco de dados.
| DEMO | BAIXAR |