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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| try
{
$bdd = new PDO('mysql:host=localhost;dbname=waxma', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$sql = "SELECT * FROM produits, typeproduits, marches,localites,marcheproduit\n"
. " where produits.TypeProduitID = typeproduits.TypeProduitID and produits.TypeProduitID = \'cereale\' and \n"
. " marches.LocaliteID = localites.LocaliteID AND produits.ProduitID = marcheproduit.ProduitID and marches.marcheID=marcheproduit.MarcheID LIMIT 0, 4 ";
$reponse = $bdd->query($sql);
$donnees= $reponse->fetchAll(PDO::FETCH_ASSOC);
echo '<table>
<tr>
<td> Nom produit </td>
<td> Prix Produit</td>
<td> Marches</td>
<td> Localité</td>
</tr>
</thead>';
$cpt=0;
foreach($donnees as $donnees)
{
echo '<tr>';
echo '<td>'. $donnees['ProduitNom'].' </td>';
echo '<td>'. $donnees['PrixVente'].' </td>';
echo '<td>'. $donnees['MarcheNom'].' </td>';
echo '<td>'. $donnees['LocaliteNom'].' </td>';
echo '</tr>';
$cpt++;
}
echo '</table>';
$reponse->closeCursor();
}
?> |