bonjour
j'ai un code php qui génére un fichier xml je veux faire un retour à la ligne en xml .
voici le code :
<html>
<body>
<?php
// Déclaration des paramètres de connexion
$host = "localhost";
// Généralement la machine est localhost
// c'est-a-dire la machine sur laquelle le script est hébergé
$user = "root";
$bdd = "sportnews";
$passwd = "";
// Connexion au serveur
mysql_connect("localhost","root","") or die("erreur de connexion au serveur");
mysql_select_db("sportnews") or die("erreur de connexion a la base de donnees");
// Creation et envoi de la requete
$query = "select news from sport";
$querya = "select resultat from sport";
$queryb = "select tv from sport";
$result = mysql_query($query);
$resulta = mysql_query($querya);
$resultb = mysql_query($queryb);
function genererxml() {
global $result;
global $resulta;
global $resultb;
$xml = '<view height="375" width="320" >'.'<script src="main.js" />'.'<img enabled="true" hitTest="htclient" name="img1" x="1" y="0" src="images\background.png" />'.'<img name="imgTabNews" x="2" y="44" src="images\tab_news.png" visible="false" />'.'<img name="imgTabResultat" x="92" y="44" src="images\tab_resultat.png" visible="false" />'.'<img name="imgTabTv" x="227" y="44" src="images\tab_tv.png" visible="false" />'.'<label height="25" name="txtNews" width="82" x="7" y="48" bold="true" enabled="true" onclick="ChangeTab(0)"align="center" valign="middle" cursor="hand" color="#FFFFFF" font="Arial" size="10">NEWS</label>'.'<label height="25" name="txtResultat" width="128" x="97" y="48" enabled="true" onclick="ChangeTab(1)"align="center" valign="middle" cursor="hand" bold="true" color="#FFFFFF" font="Arial" size="10">RESULTAT</label>'.'<label height="25" name="txtTv" width="78" x="233" y="48" bold="true" enabled="true" onclick="ChangeTab(2)"align="center" valign="middle" cursor="hand" color="#FFFFFF" font="Arial" size="10">TV
</label>';
/*if (!$result) {
die('Requête invalide : ' . mysql_error());
}
if (!$resulta) {
die('Requête invalide : ' . mysql_error());
}
if (!$resultb) {
die('Requête invalide : ' . mysql_error());
}*/
$xml .= '<div height="220" name="News" width="312" x="4" y="73" autoscroll="true" visible="true" >';
$xml .= '<a name="fact_title" font="Arial" size="11" bold="true" x="10" y="10" width="280" height="200"
underline="false" color="#03528D">';
while ($row = mysql_fetch_array($result)) {
$xml .=$row['news'];
echo $row['news'].'<br>';
}
$xml .='</a>';
$xml .= '<img name="balle" x="100" y="120" src="images\ball2.png"/>';
$xml .='</div>';
$xml .= '<div height="220" name="resultat" width="312" x="4" y="73" autoscroll="true" visible="true" >';
$xml .= '<a name="fact_title" font="Arial" size="11" bold="true" x="10" y="10" width="280" height="200"
underline="false" color="#03528D">';
while ($row = mysql_fetch_array($resulta)) {
$xml .=$row['resultat'];
echo $row['resultat'].'<br>';
}
$xml .='</a>';
$xml .= '<img name="balle" x="100" y="120" src="images\ball2.png"/>';
$xml .='</div>';
$xml .= '<div height="220" name="tv" width="312" x="4" y="73" autoscroll="true" visible="true" >';
$xml .= '<a name="fact_title" font="Arial" size="11" bold="true" x="10" y="10" width="280" height="200"
underline="false" color="#03528D">';
while ($row = mysql_fetch_array($resultb)) {
$xml .=$row['tv'];
echo $row['tv'].'<br>';
}
$xml .='</a>';
$xml .= '<img name="balle" x="100" y="120" src="images\ball2.png"/>';
$xml .='</div>';
$xml .= '</view>';
$ecrire= fopen("C:\\Users\\user\\Desktop\\widget a onglets.widget\\newssport.xml", "w+");
fputs($ecrire, $xml);
fclose($ecrire);
}
genererxml();
?>
</body>
</html>
merci pour votre aide.