Je cherche à faire une requête simple en PHP mais le problème c'est l'index que je veux afficher n'est pas le bon c'est celui d'une autre requête qui est dans la même fonction.
Sachant que ma requête marche quand je la fais sur phpMyAdmin
Je m'explique,
Ma requête :
SELECT quantite, nom
fromtype T INNERJOIN pbtyperelation PT ON T.id = PT.type_id INNERJOIN pb P ON PT.pb_id = P.id
WHERE PT.pb_id = P.id AND P.id =569(un id au hasard de la table pb)
Mon code PHP :
$req='SELECT description FROM act A inner join pb P INNER JOIN pbvillerelation R inner join ville V inner join departement D WHERE A.pbId= P.id AND P.id = R.pb_id AND R.ville_id = V.id AND V.dep_id = D.id AND P.id = :id ORDER BY A.id DESC LIMIT 1';$stmt=$this->getBdd()->prepare($req);$stmt->bindValue(":id",$id, PDO::PARAM_INT);$stmt->execute();$resultatA=$stmt->fetchAll(PDO::FETCH_ASSOC);$stmt->closeCursor();$act="";foreach($resultatAas$result){$act=$result['description'].' | ';}$req='SELECT quantite, nom from type T INNER JOIN pbtyperelation PT ON T.id = PT.type_id INNER JOIN pb P ON PT.pb_id = P.id WHERE PT.pb_id = P.id AND P.id = :id';$stmt->bindValue(":id",$id, PDO::PARAM_INT);$stmt->execute();$resultatC=$stmt->fetchAll(PDO::FETCH_ASSOC);$stmt->closeCursor();var_dump($resultatC);$cab="";if($resultatC!=""){foreach($resultatCas$result){$cab.=$result['quantite'].'m de '.$result['nom'];}}else{$cab=" Aucun cab. ";}echo$act.$cab;
Mes erreurs :
Notice: Undefined index: quantite in C:\Applications\wamp64\www\xxx\xxxx\xxxx.class.php on line 1420
Notice: Undefined index: nom in C:\Applications\wamp64\www\xxx\xxxx\xxxx.class.php on line 1420