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
|
function CreationXmlFicheClient ($NomCli)
{
//Requête des informations client
$reqInfCli = "SELECT * FROM client WHERE nomcli='$NomCli'";
$InfoCli = mysql_query($reqInfCli) or die("Impossible");
//Ouverture ou création du fichier permettant l'écriture du fichier XML
$file= fopen("FicheClient.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .="<?xml-stylesheet type='text/xsl' href='FicheClient.xsl'?>\r\n";
$_xml .="<client>\r\n";
//Boucle des informations clients
while ($row = mysql_fetch_array($InfoCli))
{
if ($row["nomcli"]) //Nom
{
$_xml .= "\t<nom>" . $row["nomcli"] . "</nom>\r\n";
}
if ($row["adressecli"]) //Adresse
{
$_xml .= "\t<adresse>" . $row["adressecli"] . "</adresse>\r\n";
}
if ($row["cpcli"]) //Code Postal
{
$_xml .= "\t<codePostal>" . $row["cpcli"] . "</codePostal>\r\n";
}
if ($row["cpcli"]) //Ville
{
$_xml .= "\t<ville>" . $row["villecli"] . "</ville>\r\n";
}
}
}
$_xml .="</client>";
fwrite($file, $_xml); //Ecriture des informations dans le fichiers
fclose($file);
}
} |