Bonjour,
Je cherche à récupérer une requête dans un tableau, ma requête fonctionne mais pas mon affichage.
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
try{
	 $c = new PDO("mysql:host=$host;dbname=$dbname",$login,$password);//Connexion à la base de données
	 $c->exec("set names utf8");
	 $req1= "SELECT Nom_entreprise,Date_Heure,Valeur,Quantite,Nom_operation,Nom_Typeinvest 
	 FROM entreprise,historique,operation,type_investissement 
	 where entreprise.ID_entreprise=historique.ID_entreprise and
	 Historique.ID_operation=operation.ID_operation and 
	 historique.ID_Typeinvest=type_investissement.ID_Typeinvest ";// Requête récupérant les entreprises
 
 
echo " <table><tr><th>Entreprise<th> <th>Opération</th> <th>Date</th> <th>Valeur</th> <th>Quantité</th> <th>Type investissement</th> </tr></table>";
foreach($c->query($req1) as $l)// On remplit le tableau à l'aide de la requête
{       
         echo "<tr><td>". $l["Nom_entreprise"] . "</td><td>" . $l["Nom_operation"] . "</td><td>" . $l["Date_Heure"]. "</td>";
		 echo "<td>". $l["Valeur"] . "</td><td>" . $l["Quantite"] . "</td><td>" . $l["Nom_operation"]. "</td><td>". $l["Nom_Typeinvest"]."</td></tr>";
 
 
}
 echo "</table>";	    
 
} catch (PDOException $err){
	echo "<p>Erreur:". $erreur->getMessage()."</p>\n";
}
 
 
 
 
?>
Merci de m'aider.