Code : Tout sélectionner
<?
$table_name = 'sequence_table';
$sql = "SELECT * FROM ".$table_name;
$result = mysql_query($sql) or die ("Impossible d'effectuer la requete : ".mysql_error());
$sql_image = "SELECT * FROM image_table Order By chord_id ASC" ;
$result_image = mysql_query($sql_image) or die ("Impossible d'effectuer la requete : ".mysql_error());
$sql_fingers = "SELECT * FROM chords_table Order By chord_id ASC" ;
$result_fingers = mysql_query($sql_fingers) or die ("Impossible d'effectuer la requete : ".mysql_error());
$num = mysql_num_rows($result);
$num_chords = mysql_num_rows($result_image);
if ($num != 0) {
$file= fopen("xml/chords.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .="<library>\r\n";
//ajout des accords
$_xml .="\t<chords>\r\n";
while ($row_chord = mysql_fetch_array($result_image)) {
if ($row_chord["chord_id"]) {
$_xml .="\t\t<chord chord_name =\"" . $row_chord["chord_name"] . "\" chord_url=\"" .$row_chord["image_src"]. "\" >\r\n";
while($row_fingers = mysql_fetch_array($result_fingers)) {
/*-------------------------------------------------------
LE PROBLEME SE SITUE DANS LE IF SUIVANT:
A CET ENDROIT LE IF EST CENSE VERIFIE SI LES CHORD_ID CORRESPONDENT BIEN ENTRE LES DEUX TABLES ET LE CAS ECHEANT RECUPERER CHORD_FINGER DANS LA PREMIERE TABLE OR IL NE LE FAIT QUE POUR LE 1ER CHORD_ID COMME VISIBLE DANS LE XML.*/
if ($row_fingers["chord_id"] == $row_chord["chord_id"]) {
$_xml .="\t\t<finger touch =\"" . $row_fingers["chord_finger"] . "\" />\r\n";
}
//-------------------------------------------------------
}
}
$_xml .="\t</chord>";
}
$_xml .="\t</chords>";
//ajout des séquences
$_xml .="\t<songs>\r\n";
while ($row = mysql_fetch_array($result)) {
if ($row["sequence_name"]) {
$_xml .="\t\t<sequence name =\"" . $row["sequence_name"] . "\" structure=\"" .$row["sequence_structure"]. "\" src=\"".$row["sequence_loop"]."\" src2=\"".$row["sequence_loop2"]."\" />\r\n";
} else {
$_xml .="\t<page title=\"Nothing Returned\">\r\n";
$_xml .="\t\t<file>none</file>\r\n";
} }
$_xml .="\t</songs>\r\n";
$_xml .="</library>";
fwrite($file,$_xml);
fclose($file);
print("<a href='xml/chords.xml'>Voir le XML</a>");
} else {
print("No Records found");
}
?>
Code : Tout sélectionner
<library>
-
<chords>
-
<chord chord_name="C7" chord_url="img/chords/C7.gif">
//LA BOUCLE N EST EXECUTEE QU ICI
<finger touch="barred"/>
<finger touch="simple"/>
<finger touch="simple"/>
//------------------------------------------
</chord>
<chord chord_name="F7" chord_url="img/chords/F7.gif">
</chord>
<chord chord_name="G7" chord_url="img/chords/G7.gif">
</chord>
</chords>
-
<songs>
<sequence name="Blues en Do" structure="C7-F7-C7-C7-F7-F7-C7-C7-G7-F7-C7-C7" src="loops/bluesC90bpm.mp3" src2="loops/bluesC130bpm.mp3"/>
</songs>
</library>