PHP Classes

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

Recommend this page to a friend!
  Classes of Adnane EL Mouttaki   Covoiturage Libre   www/ws/v1.0/getvilles.php   Download  
File: www/ws/v1.0/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: 6 years ago
Size: 857 bytes
 

Contents

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

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

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

$query = "SELECT commune as ville FROM `villes_ws` WHERE 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']) . '" />';
    }
   
mysql_free_result($RSvilles);
   
   
$xmlstr .= '</villes>';
   
   
} else {
   
$xmlstr .= '<villes/>';
}

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