Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/gen_rech_region2.php
<?php

	#########################################################################################
	# Recherche par région dans les propositions de Pnyx - script bdd						#
	# Auteur : V. Blais																		#
	# Création : 2006-04-05																	#
	# Modification : 2008-09-03																#
	# 																						#
	# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour	des	élèves	#
	# du primaire et du secondaire, dans lequel ils sont amenés à faire des	propositions	#
	# en ligne et voter pour leur favorite, sous la supervision d'un enseignant.			#
	#																						#
    # Copyright (C) <2008 - 2009>															#
	# <Service national du RÉCIT de l'univers social de la Commission scolaire de la		#
	# Pointe-de-l'Île>																		#
	#																						#
	# This program is free software; you can redistribute it and/or modify it under the 	#
	# terms of the GNU General Public License as published by the Free Software Foundation.	#
	# This program is distributed in the hope that it will be useful, but WITHOUT ANY 		#
	# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 		#
	# PARTICULAR PURPOSE.  See the GNU General Public License for more details.				#
	# You should have received a copy of the GNU General Public License along with this 	#
	# program as the file LICENSE.txt; if not, please see 									#
	# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.									#
	# 																						#
	# Service national du RÉCIT de l'univers social											#
	# http://www.recitus.qc.ca																#
	# Contact e-mail : steve-hide@address.com												#
	#########################################################################################

	require "entete_php.php";

		# verifier si la session est valide 
		# puis verifier si l'usager dispose des autorisations requises
		# pour la saisie
		verifier_session();
		
		$requete_sql = "SELECT *
						FROM ecole EC
						WHERE ecole_id = 1
						";
		$reponse_ec = bd_executer_sql($requete_sql);
		$inputString = "<markers>";
		
	while ($ligne_ec = mysql_fetch_array($reponse_ec)){
	
		$inputString .= "<marker lat=\"".$ligne_ec[latitude]."\" lng=\"".$ligne_ec[longitude]."\" html='".$ligne_ec[nom]."' />";
	}
	$inputString .= "</markers>";
	$fp = fopen( "ecoles.xml" , "w" );
		if(!$fp)
{
    echo "Couldn't open the data file. Try again later.";
    exit;
}
fwrite( $fp, $inputString );
fclose( $fp );
			
?>
<!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>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Cliquez pour moi!</title>

<meta name="description" content="«Cliquez pour moi!» est un site pour les enseignants et les élèves du primaire et du secondaire. Faites campagne pour mettre de l'avant vos propositions et venez voter le jour des élections!" />

<script type="text/javascript" src="lib/fonctions.js"></script>

<link rel="SHORTCUT ICON" href="http://www.recitus.qc.ca/cliquezpourmoi/favicon.ico">
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAiPHnCmZxP-P-WY23_FKOlhRF4D7QFpj0T69l9Am2CEfAxRxbMhQ2OvQciCP4aFPi7ytSUlScqssB2A" type="text/javascript"></script>
</head>
<body onload="MM_preloadImages('images/menu_accueil_glow.gif','images/menu_projet_glow.gif','images/menu_guide.gif','images/menu_voir_glow.gif','images/menu_logout_glow.gif','images/menu_pied_contact_glow.gif','images/menu_pied_confid_glow.gif','images/menu_pied_credit_glow.gif')">
<div id="map" style="width: 700px; height: 400px;"></div>
<script type="text/javascript">     
var map = new GMap(document.getElementById("map2"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-71.740723, 48.122101), 11);
map.setMapType(G_SATELLITE_TYPE);
</script>

<script type="text/javascript">
    if (GBrowserIsCompatible()) {
      // this variable will collect the html which will eventually be placed in the sidebar
      var sidebar_html = "";
    
      // arrays to hold copies of the markers and html used by the sidebar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;


      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        // FF 1.5 fix
        html = '<div style="white-space:nowrap;">' + html + '</div>';
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the sidebar
        gmarkers[i] = marker;
        htmls[i] = html;
        // add a line to the sidebar html
        sidebar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }


      // create the map
      var map = new GMap(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.centerAndZoom(new GPoint(-71.740723, 48.122101), 11);
	  map.setMapType(G_HYBRID_TYPE);


      // Read the data from example.xml
      var request = GXmlHttp.create();
      request.open("GET", "ecoles.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = request.responseXML;
          // obtain the array of markers and loop through it
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");

          for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GPoint(lng,lat);
            var html = markers[i].getAttribute("html");
            var label = markers[i].getAttribute("label");
            // create the marker
            var marker = createMarker(point,label,html);
            map.addOverlay(marker);
          }
          // put the assembled sidebar_html contents into the sidebar div
          document.getElementById("sidebar").innerHTML = sidebar_html;
        }
      }
      request.send(null);
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    </script>
</body>
</html>
Return current item: Pnyx : des lections virtuelles!