Au premier appelle tout s'affiche avec les données comme dans la base, mais quand je modifie les données dans la base; les données restent celui du premier appel. Je ne vois pas ou est le problème.
MySQL :
Code sql : 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 CREATE TABLE IF NOT EXISTS `agent` ( `id_phone` int(255) NOT NULL AUTO_INCREMENT, `imei` varchar(30) COLLATE utf8_bin NOT NULL, `nom_utilisateur` varchar(30) COLLATE utf8_bin NOT NULL, `nom_phone` varchar(30) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id_phone`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ; -- -- Contenu de la table `agent` -- INSERT INTO `agent` (`id_phone`, `imei`, `nom_utilisateur`, `nom_phone`) VALUES (1, '000000000000001', 'RASOA', 'Samsung'), (2, '000000000000000', 'SAMUEL', 'Xperia'); -- -- Structure de la table `coordonnees` -- CREATE TABLE IF NOT EXISTS `coordonnees` ( `id_coordonne` int(255) NOT NULL AUTO_INCREMENT, `latitude` float NOT NULL, `longitude` float NOT NULL, `date` date NOT NULL, `heure` time NOT NULL, `imei` varchar(30) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id_coordonne`), UNIQUE KEY `heure` (`heure`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=18 ; -- -- Contenu de la table `coordonnees` -- INSERT INTO `coordonnees` (`id_coordonne`, `latitude`, `longitude`, `date`, `heure`, `imei`) VALUES (12, 47.423, -18.0846, '0000-00-00', '08:59:59', '000000000000001'), (13, 47.422, -18.0846, '2014-01-29', '07:54:30', '000000000000000'), (14, 47.4221, -18.0848, '2014-01-29', '07:54:36', '000000000000001'), (17, 47.4222, -18.0848, '2014-01-29', '07:57:16', '000000000000000');
html code :
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Remove Markers</title> <meta name="description" content="Custom Drop-Down List Styling with CSS3" /> <meta name="author" content="Codrops" /> <link rel="shortcut icon" href="../favicon.ico"/> <link rel="stylesheet" type="text/css" href="../css/style.css" /> <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css' /> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } #panel { position: absolute; top: 5px; left: 50%; margin-left: -180px; z-index: 5; background-color: #fff; padding: 5px; border: 1px solid #999; } </style> <!-- PHP code--> </head> <body> <div id="map-canvas"></div> <!-- Creation du map--> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script > var map; var markers = []; var contentString = []; function initialize() { var myLatlng = new google.maps.LatLng(47.422,-18.0845); var mapOptions = { zoom: 20, center: myLatlng }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var interval = setInterval (function(){ var json_data = <?php require ('../classes/Connection.class.php'); $connection = new Connection (SERVER,DATABASE,USER,PASSWORD); $result; $select = $connection->select('SELECT * from coordonnees '); if ($select != null){ $result = $connection->resultQueryCoordonneesToArray(); } $select = $connection->select('SELECT * from agent'); if ($select != null){ $result = $connection->resultQueryAgentsToArray(); } echo json_encode($result); $result = null; ?>; for (var i=0 ; i<json_data.coordonnees.length ;i++){ markers[i] = new google.maps.LatLng(json_data.coordonnees[i].latitude,json_data.coordonnees[i].longitude); for(var j = 0; j< json_data.agents.length ; j++){ if (json_data.agents[j].imei === json_data.coordonnees[i].imei){ contentString[i] = ""+json_data.agents[j].nom_utilisateur; } } } alert(json_data.agents[0].nom_utilisateur); /* * Ajout des infos windows sur les **/ var infowindow = []; for (i = 0 ; i < contentString.length ; i++){ infowindow[i] = new google.maps.InfoWindow({content: contentString[i]}); } for (i = 0 ; i < markers.length ; i++){ var marker = new google.maps.Marker({ position: markers[i], map: map //title: contentString[i]; }); // Ajout des infos windows sur le marqueur infowindow[i].open(map,marker); google.maps.event.addListener(marker, 'click', function() { infowindow[i].open(map,marker); }); } // fin for markers[0].setMap(null); },5000); // fin du variable interval } // fin function initialize() // Add a marker to the map and push to the array. function addMarker(location) { var marker = new google.maps.Marker({ position: location, map: map }); markers.push(marker); } // Sets the map on all markers in the array. function setAllMap(map) { for (var i = 0; i < markers.length; i++) { markers[i].setMap(map); } } // Removes the markers from the map, but keeps them in the array. function clearMarkers() { setAllMap(null); } // Shows any markers currently in the array. function showMarkers() { setAllMap(map); } // Deletes all markers in the array by removing references to them. function deleteMarkers() { clearMarkers(); markers = []; } google.maps.event.addDomListener(window, 'load', initialize); </script> </body> </html>
Partager