<?php
include_once '../inc/functions.php';

$city=$_GET['city'];
//$sql = "select pharmacies.id,name from pharmacies left join surveys on pharmacies.id=pharmacy_id where pharmacy_id is null and city ='$city' order by name";


$pharmacies = R::getAll("select id,name from pharmacies where city ='$city' order by name");
foreach ($pharmacies as $p) {

    $id = $p['id'];
    $name = $p['name'];

    $pharmacie = R::getAll("select pharmacy_id from surveys where pharmacy_id ='$id'");
    if(count($pharmacie)==0)
        echo "<option id='$id' value='$id'>$name</option>";
    else
        echo "<option disabled id='$id' value='$id'>$name</option>";
}
echo '<option id="999" value="Nouvelle pharmacie">Nouvelle pharmacie</option>';
?>