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 40 41 42
|
<?php
// édition du début du fichier XML
$xml = '<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">';
$xml .= '<channel>';
$xml .= '<title>Titre du channel</title>';
$xml .= '<link>http://www.monsite.com</link>';
$xml .= '<description>Description du channel</description>';
// connexion a la base
@mysql_connect(localhost,rrrrrrrrr,rrrrrrr) or die("Connexion impossible");
@mysql_select_db(directassoc) or die("Echec de selection de la base");
// selection des 5 dernieres news
$res=mysql_query("SELECT * FROM message ORDER BY datevent DESC LIMIT, 5");
// extraction des informations et ajout au contenu
while($tab=mysql_fetch_array($res))
echo mysql_error().' '.$res ;
{
$titre=$tab[titre];
$lien=$tab[lien];
$description=$tab[description];
$date=$tab[date];
$date2=date("D, d M Y H:i:s", strtotime($date));
$xml .= '<item>';
$xml .= '<title>'.$titre.'</title>';
$xml .= '<link>'.$lien.'</link>';
$xml .= '<pubDate>'.$date2.' GMT</pubDate>';
$xml .= '<description>'.$description.'</description>';
$xml .= '</item>';
}
// édition de la fin du fichier XML
$xml .= '</channel>';
$xml .= '</rss>';
// écriture dans le fichier
$fp = fopen("flux.xml", 'w+');
fputs($fp, $xml);
fclose($fp);
@mysql_close();
?> |