Aquí voy a compartir una base de datos útil que es la lista de códigos STD de la India en MYSQL y EXCEL con el script del buscador de códigos STD en PHP, MYSQL, JQUERY.
Si planea crear un sitio web basado en telecomunicaciones, entonces puede ayudarlo. Aquí he compartido la base de datos completa con el script. En el script del buscador de código STD, utilicé la función de autocompletar jquery. Puede leer el tutorial sobre cómo crear autocompletar / automático. -sugerir
Empecemos el tutorial
Crea tu archivo html. con algo de css y javascript requerido, no olvides incluir la 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="http://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="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://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> |
Cree un archivo de servidor para obtener datos de la base de datos y devolverlos en 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 el botón a continuación para ver una demostración en vivo y descargar el código fuente con la base de datos.
DEMO | DESCARGAR |