Bonjour,
Dans mon fichier php, j'ai une partie de code javascript et je réalise une boucle php (boucle for) qui a pour but de générer le texte qui alimentera alors le code javascript.
Ca ne marche pas à l'affichage, pourtant lorsque je vais voir le code source depuis internet le texte s'est bien imprimé!
Quelqu'un peut-il m'éclairer?
Voici mon code :
Code PHP :
<?php
$requete1="select * from $base1 ORDER BY id";
$result1 = pg_query($dbconn,$requete1);
$i=0;
$tab1 = pg_fetch_all($result1);
$taille_tab1 = sizeof($tab1);
for ($i=0; $i<$taille_tab1; $i++) {
$tab1[$i] = pg_fetch_assoc($result1,$i);
}
$j=0;
for ($j=0; $j<$taille_tab1; $j++) { //pour chaque camera
// Recherche dans la table tampon de la DATE LA PLUS RÉCENTE pour la caméra
$requete2 = "SELECT id,max(date) FROM $base2 WHERE id='".$tab1[$j]["id"]."' GROUP BY id";
$result2 = pg_query($dbconn,$requete2);
$k=0;
$tab2 = pg_fetch_all($result2);
$taille_tab2 = sizeof($tab2);
for ($k=0; $k<$taille_tab2; $k++) {
$tab2[$k] = pg_fetch_assoc($result2,$k);
$date[$j] = $tab2[$k]["max"];
}
?>
Code Javascript :
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" charset="utf-8" src="http://mapstraction.googlecode.com/svn/trunk/source/mxn.js?(openlayers)"></script>
<script type="text/javascript">
function initialize() {
// initialise the map with your choice of API
var mapstraction = new mxn.Mapstraction('map_canvas','openlayers');
// variable avec coordonnées de Strasbourg
var myPoint = new mxn.LatLonPoint(48.32,6.2);
// carte centrée sur Strasbourg et niveau de zoom (Google zoom levels)
mapstraction.setCenterAndZoom(myPoint, 6);
mapstraction.addControls({
pan: true,
zoom: 'small',
map_type: true
});
<?php
$i=0;
for ($i=0; $i<$taille_tab1; $i++)
{
echo 'mapstraction.addMarkerWithData(new mxn.Marker( new mxn.LatLonPoint(47.5877,6.843)),{
infoBubble : '.$tab1[$i]["nom"].' <br> <A HREF=\'http://dorade.meteo.fr/TENEBRE/'.$tab1[$i]["id"].'_'.$date[$i].'.jpg\'> <img src=\'http://dorade.meteo.fr/TENEBRE/'.$tab1[$i]["id"].'_'.$date[$i].'.jpg\'WIDTH=150 HEIGHT=100> </A>",
label : "tooltip",
date : "new Date()",
marker : 4,
icon :\'http://upload.wikimedia.org/wikipedia/fr/a/a6/LogoMeteoFrance.png\',
iconSize : [40,20],
draggable : false,
hover : false
});
';
}
?>
}
</script>
Merci d'avance!