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
//dans le cas ou il ya une erreur au niveau de la connexion à la base de données la partie dans le catch s'exécutera et se sera la fin
try
{
//host= le server ,dbname= ta base de données, root= le nom de l'utilisateur, ''= le mot de passe
$bdd = new PDO('mysql:host=localhost;dbname=datacom', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
IF ($truc==0)
{
$reponse = $bdd->query("SELECT * FROM menu where type='restaurant' ");
while ( $don = reponse->fetch())
{
//ici tu fais ton affichage dans ta table
}
}
ELSE
{
$reponse = $bdd->query("SELECT * FROM menu where type='restaurant' ");
while ( $don = reponse->fetch())
{
//ici tu fais ton affichage dans ta table
}
}
?> |