added showVoiture function

This commit is contained in:
Flavien Haas 2019-05-07 00:38:50 +02:00
parent 17c99d1792
commit 6bf770143a

View File

@ -1,15 +1,14 @@
<?php
/*require ('../connectionBD.php');
require ('../connectionBD.php');
$mail = null;
$db = connexionBD();
init();
*/
$matricule = $_POST['matricule'];
$marque = $_POST['marque'];
$modele = $_POST['modele'];
$nbplaces = $_POST['nbplaces'];
$anneefab = $_POST['anneefab'];
$matricule = isset($_POST['matricule']) ? $_POST['matricule'] : NULL; //recuperation valeur formulaire, isset pour eviter l'erreur "Notice: Undefined index"
$marque = isset($_POST['marque']) ? $_POST['marque'] : NULL;
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
if(isset($_POST['submitadd']))
{
@ -38,26 +37,29 @@ function init(){
}
function addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){
//global $db;
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','mail');";
//$requete = "INSERT INTO 'public'.'voiture' ('matricule','marque','modele','nbplaces','anneefab','mail') VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','".$_SESSION['mail']."');";
echo "requete =".$requete;
//pg_query($db, $requete);
global $db;
$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($matricule, $marque, $modele, $nbplaces, $anneefab){
//global $db;
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = 'mail';";
//$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '".$_SESSION['mail']."';";
global $db;
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '".$_SESSION['mail']."';";
echo "requete =".$requete;
//pg_query($db, $requete);
pg_query($db, $requete);
}
function showVoiture(){
//global $db;
$requete = "SELECT * FROM voiture WHERE voiture.mail = '".$_SESSION['mail']."';";
echo "requete =".$requete;
//pg_query($db, $requete);
global $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>";
}
}
}
?>