You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

<?php
header('Content-type: application/json;charset=utf-8');
//phpinfo();
if($_SERVER['REQUEST_METHOD'] === "GET")
{
if(preg_match("/^\/b1api\/vol\/liste/",$_SERVER['REDIRECT_URL']))
{
$mysqli = new mysqli("localhost", "root", "", "b1eval");
if ($mysqli->connect_errno) {
header('HTTP/1.1 500 OK');
echo json_encode( array('erreur mysql' => "Échec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error));
}
else {
$resultat = $mysqli->query('SELECT * FROM `vol`');
$ligne_de_resultat = $resultat->fetch_array(MYSQLI_ASSOC);
header('HTTP/1.1 200 OK');
echo json_encode( $ligne_de_resultat);
}
}
else
{
header('HTTP/1.1 404 OK');
echo json_encode( array('erreur' => "route inconnue ".$_SERVER['REQUEST_URI']) );
}
}
else
{
header('HTTP/1.1 404 OK');
echo json_encode( array('erreur' => "METHODE NON SUPPORTEE : ".$_SERVER['REQUEST_METHOD']));
}