| 12
 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
 
 |  
$contenu="<root>"
$sql="select distinct Num,Type from table";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
   $contenu.="<num1='$row[0]' type='$row[1]'>";
   $sql="select distinct Nom from table where Num=$row[0] and Type=$row[1]";
   $result1=mysql_query($sql);
   while($row1=mysql_fetch_array($result1))
   {
     $contenu.="<nom nom='$row1[0]'>";
     $sql="select distinct Codesite from table where Num=$row[0] and Type=$row[1] and Nom=$row1[0]";
     $result2=mysql_query($sql);
     while($row2=mysql_fetch_array($result2))
     {
      $contenu.="<Code CodeSite='$row2[0]'>";
      $sql="select  CP from table where Num=$row[0] and Type=$row[1] and Nom=$row1[0] and Codesite=$row2[0]";
      $result3=mysql_query($sql);
      while($row3=mysql_fetch_array($result3))
      {
       $contenu.="<CP = '$row3[0]'></CP>";
      }
      $contenu.="</code>";
     }
     $contenu.="</nom>"; 
   }
   $contenu.="</num1>";
}
$contenu.="</root>";
$handle=fopen("test.xml","w");
fwrite($handle,$contenu);
fclose($handle); | 
Partager