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
|
<?php
$bdd = mysql_connect("localhost", "root", "") or die("Erreur : ".mysql_error());
mysql_select_db("ss", $bdd) or die("Erreur : ".mysql_error());
$q = "SELECT c.Id, c.nom, c.description, c.Designer, c.prix2, cp.Photo
FROM produits c
INNER JOIN photos cp
ON c.Id=cp.Id";
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'.'<catalogue>';
while ($row = mysql_fetch_array($q)) {
$xml .= '<produit>';
$xml .= '<identifiant>'.$row['Id'].'</identifiant>';
$xml .= '<nom>'.$row['nom'].'</nom>';
$xml .= '<marque>'.$row ['Designer'].'</marque>';
$xml .= '<prix_ttc>'.$row ['Prix2'].'</prix_ttc>';
$xml .= '<descriptif_court>'.$row['description'].'</descriptif_court>';
$xml .= '</produit>';
}
$xml .= '</catalogue>';
$fp = fopen("catalogue.xml", 'w+');
fputs($fp, $xml);
fclose($fp);
echo 'Export XML effectue !<br><a href="catalogue.xml">Voir le fichier</a>';
?> |
Partager