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
| <?php
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=location', 'root', 'helasfar', $pdo_options);
$result = $bdd->query('SELECT * FROM voiture');
if(!false==$result) {
while($data = $result->fetch()) {
printf (
"<tr>
<td>
<img src="$data['chemin']" />
</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>",
$data['nom'],
$data['prix'],
);
} // end while
if(mysql_num_rows($result) == 0) {
$msg.="Aucune information disponible";
}
else
{ echo "erreur mysql" ;}
}
$reponse->closeCursor();
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?> |
Partager