<?php
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
    $requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "','" . $_SESSION['mail'] . "');";
    pg_query($db, $requete);
}

function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
    $requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "') WHERE mail = '" . $_SESSION['mail'] . "';";
    pg_query($db, $requete);
}

function showVoiture($db){
    $requete = "SELECT * FROM public.voiture WHERE voiture.mail = '" . $_SESSION['mail'] . "';";
    if ($donnees = pg_query($db, $requete)) {
        while ($res = pg_fetch_assoc($donnees)) {
            echo "matricule = ".$res['matricule']."<br>";
            echo "marque = ".$res['marque']."<br>";
            echo "modele = ".$res['modele']."<br>";
            echo "nombre de places = ".$res['nbplaces']."<br>";
            echo "année de fabrication = ".$res['anneefab']."<br>";
        }
    }
}
?>
