Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

PHP, MYSQL Autocomplete tidak berfungsi

Coba kode berikut...

html

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" /> 

<p><label>Country:</label><input type='text' name='country' value='' class='auto'></p>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>


<script type="text/javascript">
$(function() 
{
    $(".auto").autocomplete({
        source: "autocomplete.php",
        minLength: 1
    });
});
</script>

pelengkapan otomatis.php

<?php

mysql_connect("localhost", "root", "")or die("cannot connect"); 
mysql_select_db("test")or die("cannot select DB");

$query = $_GET['term'];

$mysql_query = mysql_query("SELECT * FROM users WHERE name LIKE '%{$query}%'");

while ($row = mysql_fetch_assoc($mysql_query))
{
    $array[] = $row['name'];
}
echo  json_encode ($array);


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Kontrol Akses MySQL

  2. PHP Mysql bergabung di seluruh database

  3. Dapatkan posisi baris dalam kueri MYSQL

  4. phpMyAdmin - Kesalahan> Parameter format salah?

  5. MySQL Update Inner Join tabel query