<?php
#########################################################################################
# Fonctions AJAX de Pnyx #
# Auteur : B. Leblanc #
# Création : 2008 #
# Modification : 2008 #
# #
# 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 #
#########################################################################################
//$_POST = array_map(utf8_decode(), $_POST);
require "constantes.php";
//header('Content-Type: text/html; charset=ISO-8859-1');
$connection = mysql_connect($HOTE,$USAGER,$MOTPASSE) or die("Impossible de se connecter : " . mysql_error());
// Sélectionne une base de données MySQL, si cela n'est pas possible alors fin de l'exécution du code
if (!mysql_select_db($BD)){
die("Impossible d'accéder à la base de données : " . mysql_error());
}
$tabEcole = array();
if($_POST['choix'] != ""){
$requete_sql = "SELECT * FROM ecole WHERE comscol_id = '" . $_POST['choix'] . "' AND actif = '1'";
}
else if($_POST['region'] != ""){
$requete_sql = "SELECT E.ecole_id, E.nom
FROM ecole AS E, commission_scolaire AS CS, region AS R
WHERE R.region_id = " . $_POST['region'] . "
AND R.region_id = CS.region_id
AND CS.comscol_id = E.comscol_id
AND actif = '1'";
}
else{
$requete_sql = "SELECT * FROM ecole WHERE actif = '1'";
}
$reponse_ecole = mysql_query($requete_sql);
while($ligne_ecole = mysql_fetch_array($reponse_ecole)){
$ecoleID = $ligne_ecole['ecole_id'];
$ecoleNom = $ligne_ecole['nom'];
$tabEcole[$ecoleID] = $ecoleNom;
}
$html = "";
$html .= "<select name=\"ecole\" id=\"lstEcole\" size=\"1\">";
$html .= "<option value=''>Choisissez une école</option>";
foreach($tabEcole as $ecoleID => $ecoleNom){
$html .= "<option value='" . $ecoleID . "'>" . utf8_encode($ecoleNom) . "</option>";
}
$html .= "</select>";
mysql_close($connection);
echo $html;
?>