PHP Classes

File: www/ws/v1.1/getvilles.php

Recommend this page to a friend!
  Classes of Adnane EL Mouttaki   Covoiturage Libre   www/ws/v1.1/getvilles.php   Download  
File: www/ws/v1.1/getvilles.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Covoiturage Libre
Web application for managing a carpoling site
Author: By
Last change:
Date: 7 years ago
Size: 1,093 bytes
 

Contents

Class file image Download
<?php
if (!isset($_GET['debut']) or empty($_GET['debut'])) {
    die();
}

$pays = 'FR';
$Pays = array('FR', 'DE', 'BE', 'IT', 'CH');
if (!empty(
$_GET['pays']) && in_array($_GET['pays'], $Pays)) {
   
$pays = $_GET['pays'];
}

require_once(
'../../Connections/bddcovoiturette.php');
mysql_select_db($database_bddcovoiturette, $bddcovoiturette);

$ville = mysql_real_escape_string(stripslashes($_GET['debut']));

$query = "SELECT commune as ville, cpostal FROM `villes_ws` WHERE PAYS = '" .$pays . "' AND commune LIKE '" . $ville . "%' LIMIT 20";
$RSvilles = mysql_query($query, $bddcovoiturette) or die(mysql_error());

$totalVilles = mysql_num_rows($RSvilles);
$xmlstr = '<?xml version="1.0" encoding="UTF-8"?>';
if (
$totalVilles > 0) {
   
$xmlstr .= '<villes>';
    while (
$row_RSvilles = mysql_fetch_assoc($RSvilles)) {
       
$xmlstr .= '<ville name="' . utf8_encode($row_RSvilles['ville']) . '" cp="' . utf8_encode($row_RSvilles['cpostal']) . '" />';
    }
   
mysql_free_result($RSvilles);
   
   
$xmlstr .= '</villes>';
   
   
} else {
   
$xmlstr .= '<villes/>';
}

header("Content-Type: text/xml");
echo
$xmlstr;
?>