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 43 44 45 46 47 48 49 50
| <?php
//code de connexion à la bd que j'ai enlevé
//puis
$mysql_link=mysql_connect("$server","$user","$pwd") or die ("connexion impossible !");
mysql_select_db($db, $mysql_link) or die ("impossible d'accéder à la base de données !");
$query="select IdActu, TitreAccroche, SousTitreAccroche, Accroche,Visuel, Date, CreditPhoto, Actu, Categorie.IdPage from Actualites, Categorie
where Actualites.IdCategorie=Categorie.IdCategorie
and AfficheAccueil=1 and Editer=1 order by Date DESC LIMIT 8";
/*
$query="SELECT * FROM Actualites where Actualites.IdCategorie=Categorie.IdCategorie
and AfficheAccueil=1 and Editer=1 ORDER BY date DESC LIMIT, 5";
*/
$res=mysql_query($query);
while($tab=mysql_fetch_array($res) ){
$titre=$tab['TitreAccroche'];
$lien=$tab['SousTitreAccroche'];
$description=$tab['Accroche'];
$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("http://www.fondationbrigittebardot.fr/site/rss/experimentation.xml", 'w+');
if( !$fp){die("ouverture du fichier impossible");}
fputs($fp, $xml);
fclose($fp);
@mysql_close();
?> |
Partager