Bjr, donc voilà j'ai suivie le tuto qui traite sur ce sujet mais ayant déja ma base de donnée sur les villes j'ai changer quelques info mais sa ne m'affiche plusieurs valeur dans le déroulant
http://x-zolezzi.developpez.com/tuto...utocompletion/

voila mon code pour l'index
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head >
		<title>AutoCompletion</title>
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
		<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
		<script type="text/javascript">
			var cache = {};
			$(function ()
			{
				$("#cp, #ville").autocomplete({
					source: function (request, response)
					{
						//Si la réponse est dans le cache
						if (('0' + '-' + request.term) in cache)
						{
							response($.map(cache['0' + '-' + request.term], function (item)
							{
 
								return {
									label: item.CodePostal + ", " + item.Ville,
									value: function ()
									{
										if ($(this).attr('id') == 'cp')
										{
											$('#ville').val(item.Ville);
											return item.CodePostal;
										}
										else
										{
											$('#cp').val(item.CodePostal);
											return item.Ville;
										}
									}
								}
							}));
						}
						//Sinon -> Requete Ajax
						else
						{
							var objData = {};
							if ($(this.element).attr('id') == 'cp')
							{
								objData = { CodePostal: request.term, pays: '0', maxRows: 10 };
							}
							else
							{
								objData = { ville: request.term, pays: '0', maxRows: 10 };
							}
							$.ajax({
								url: "./AutoCompletion.php",
								dataType: "json",
								data: objData,
								type: 'POST',
								success: function (data)
								{
									//Ajout de reponse dans le cache
									cache[('0' + '-' + request.term)] = data;
									response($.map(data, function (item)
									{
 
										return {
											label: item.CodePostal + ", " + item.Ville,
											value: function ()
											{
												if ($(this).attr('id') == 'cp')
												{
													$('#ville').val(item.Ville);
													return item.CodePostal;
												}
												else
												{
													$('#cp').val(item.CodePostal);
													return item.Ville;
												}
											}
										}
									}));
								}
							});
						}
					},
					minLength: 3,
					delay: 600
				});
			});
		</script>
		<link rel="Stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" />
	</head>
	<body>
		<form action="#">
			CP :<input type="text" id="cp" size="6"/>
			Ville : <input type="text" id="ville" />
		</form>
	</body>
</html>
celui de aucompletationcpville
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
 
require_once('C:\wamp\www\test\AutoCompletionCPVille.class.php');
 
//Initialisation de la liste
$list = array();
 
//Connexion MySQL
try
{
    $db = new PDO('mysql:host=localhost;dbname=goldenbook','root', '');
}
catch (Exception $ex)
{
    echo $ex->getMessage();
}
 
//Construction de la requete
$strQuery = "SELECT ville_code_postal, ville_nom FROM villes_france WHERE ";
if (isset($_POST["CodePostal"]))
{
    $strQuery .= "ville_code_postal LIKE :CodePostal ";
}
else
{
    $strQuery .= "ville_nom LIKE :Ville ";
}
$strQuery .= "AND CODEPAYS = '0' ";
//Limite
if (isset($_POST["maxRows"]))
{
    $strQuery .= "LIMIT 0, :maxRows";
}
$query = $db->prepare($strQuery);
if (isset($_POST["CodePostal"]))
{
    $value = $_POST["CodePostal"]."%";
    $query->bindParam(":CodePostal", $value, PDO::PARAM_STR);
}
else
{
 
	$value = $_POST["Ville"]."%";
    $query->bindParam(":Ville", $value, PDO::PARAM_STR);
 
}
//Limite
if (isset($_POST["maxRows"]))
{
    $valueRows = intval($_POST["maxRows"]);
    $query->bindParam(":maxRows", $valueRows, PDO::PARAM_INT);
}
 
$query->execute();
 
$list = $query->fetchAll(PDO::FETCH_CLASS, "AutoCompletionCPVille");;
 
echo json_encode($list);
?>

puisque autocompletation.php n'a pa changer je ne vous le montre pas

Merci de votre aide