|
|
|
|
Configuration: Windows XP Internet Explorer 6.0
|
<?php
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $xml .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'; $xml .= '<channel>'; $xml .= '<title>Titre du flux</title>'; $xml .= '<link>http://www.ton site.extension(fr,net)</link>'; $xml .= '<description>Description du flux</description>'; $xml .= '<copyright> ton copyright 2008</copyright>'; $xml .= '<language>Ta langue (fr,us,ca)</language>'; $xml .= '<image>'; $xml .= ' <title>titre de l'image</title>'; $xml .= ' <url>http://www.ton site.fr/dossier/ton logo</url>'; $xml .= ' <link>http://www.ton site.fr</link>'; $xml .= '</image>'; $today= date("D, d M Y H:i:s +0100"); //date du jour d'execution du fichier PHP $xml .= '<pubDate>'.$today.'</pubDate>'; //si tu le fais en dynamique require ('ton fichier de connection'); // Faîtes appel à vos fichier de connection à votre base de donnée MySQL // Adaptez ces lignes à votre base de données / noms de table $resultat_requete=mysql_query("SELECT * FROM table ORDER BY id DESC limit 10"); // extraction des 10 dernières nouvelles while($lig=mysql_fetch_array($resultat_requete)){ $titre=$lig["champs1"]; $id=$lig["champs2"]; $rub=$lig["champs3"]; $adresse="http://www.ton site.fr/ta page(Ex: index.php?rub=$rub&detail=$id)"; $contenu_in=strip_tags($lig["champs4"]);//ton contenu $contenu=substr($contenu_in,0,200)."...";//pour limiter le nombre de caracteres affiches $date=$lig["champs5"]; $xml .= '<item>'; $xml .= '<title>'.$titre.'</title>'; $xml .= '<link>'.$adresse.'</link>'; $xml .= '<guid>'.$adresse.'</guid>'; // $xml .= '<pubDate>'.$date.'</pubDate>'; $xml .= '<description>'.$contenu.'</description>'; $xml .= '</item>'; }//fin du while $xml.='<atom:link href="http://www.ton site.fr/ton fichier.xml" rel="self" type="application/rss+xml" />'; $xml .= '</channel>'; $xml .= '</rss>'; // $fp = fopen("ton fichier.xml", 'w+'); fputs($fp, $xml); fclose($fp); header("location: url de ton fichier.xml"); //remplace le header par la ligne du dessous pour tester sans redirection et pour debugguer /*echo 'Export XML effectue !<br /><a href="loca.xml">Voir le fichier</a>';*/ ?> Voilà j'espere que ça t'aideras, |
Résultats pour créer son flux rss
Résultats pour créer son flux rss
Résultats pour créer son flux rss
Résultats pour créer son flux rss
Résultats pour créer son flux rss
Résultats pour créer son flux rss